Premium alters the body and sets the teaser as the body + adds a message asking to log in

Nodevote adds the voting restults to the teaser...
Nodevote adds the voting results + voting form to the body...

All those additions get lost when using contemplate...

The hook_nodeapi() of contemplate should be executed BEFORE all other modules using this hook...
But is that possible?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ednique’s picture

Same applies when you mark a CCK content type as being an event...
Event dates get lost...

After investigation I figured out that the contemplate_nodeapi() is causing this issue...
A lot of other modules using the hook_nodeapi() are executed before the contemplate code and all get lost...
It may be better to use the hook_view() instead, just like cck does...
I changed a few lines of code and seems to work...

Once tests are completed, I post my solution.

ednique’s picture

FileSize
433 bytes

Here's my solution...
It needs a little change in the CCK module. You should ask them to add the code, or ask them to provide a hook that you can call.

	if (module_exist('contemplate')) {
	  contemplate_view($node);
	}

Next the contemplate module needs that function + a slight change in the content_nodeapi so that it is only executed for content types that are NOT CCK...

here's the CCK patch

ednique’s picture

And here's the Contemplate patch

bomarmonk’s picture

Is this patch the right solution? Can it be committed? I'm having trouble using CCK nodes as Organic Group home pages. Contemplate prevents any of the group nodes from showing on the homepage. Once I disable contemplate, there they are, but the format looks awful.

ju.ri’s picture

same problem here.
the patch worked with 4.7, but not in 5.0.

bomarmonk’s picture

The content module patch does not apply to the most recent release of CCK. Can the patch be updated to work with the newer release?

krisvannest’s picture

FWIW it also seems any editing to the Contemplate teaser field causes other modules content to be skipped. For instance, if I hit "reset" when editing my Contemplate template, the buttons for Service Links module show up on my CCK nodes fine. But if I do any manual editing to the teaser area of that same Contemplate template-- like even put in a single extra carriage return or whatever-- the Service Links buttons are then stripped when viewing the node. Hitting "reset" when editing the Contemplate template will then show them again (but that means I can't touch the template once Contemplate creates it).

bomarmonk’s picture

I suppose I should clarify my earlier statement that the content.module.patch does not work. I have tested it with the current 4.7.1-x developement and 4.7.3-release versions of CCK. In both cases the patch fails. The contemplate patch, however, seemed to work, unfortunately, the patched contemplate module no longer has any effect on the appearance of the CCK node

ednique’s picture

FileSize
1.14 KB

First off, I stopped using contemplate as the latest CCK allows you to alter the teaser and body inside the CCK code...

to help you out, I checked the changes again...

The patches first of all are for 4.7.x version...

for the content.module you have to locate the function content_view in that function you will find:

  $node->body = implode('', _content_field_view($node, FALSE, $page));
  $node->teaser = implode('', _content_field_view($node, TRUE, $page));
  $node->readmore = (strlen($node->teaser) < strlen($node->body));

change it to

  $node->body = implode('', _content_field_view($node, FALSE, $page));
  $node->teaser = implode('', _content_field_view($node, TRUE, $page));
  if (module_exist('contemplate')) {
    contemplate_view($node);
  }
  $node->readmore = (strlen($node->teaser) < strlen($node->body));

This code makes it so that contemplate is called from the CCK...

Next you need to change the contemplate module so that its normal processing is done for NON-CCK content types and the function contemplate_view needs to be added.
see attached patch...

I hope this will help...

pvasener’s picture

Your solution is perfectly working with Drupal 4.7.x and I try to adapt it for Drupal 5.x. Up to now, I have not succeeded as the alter/view mechanism seems to have changed a bit but I will post here a solution once I have one. Any hint or help is, of course, welcome...

bomarmonk’s picture

Why hasn't this patch been included for both projects? I am trying to bring some attention to this issue with this thread:
http://drupal.org/node/162042

bomarmonk’s picture

Status: Active » Needs review
bomarmonk’s picture

Version: 4.7.x-1.x-dev » 6.x-1.x-dev

Any work on a fix for this issue on CCK 6? This problem may not prevent the module from being used, but it does make it much more difficult to use with book pages, etc. where other modules should be automatically adding links or content to a node.

dopry’s picture

No CCK will not call contemplate directly... ever!

lovedrupal6’s picture

the solution i got from http://drupal.org/node/265728

replace your contemplate template code with this:

<?php
ob_start(); ?>


// ... PASTE YOUR TEMPLATE HERE......


<?php
$node->content['body']['#value'] = ob_get_contents();
ob_end_clean();

// iterate through each child elements
foreach (element_children($node->content) as $key) {
  // we skip child elements which name preceeded by 'field_'
  if (substr($key, 0, 6) == 'field_') continue;
  // print child element
  print $node->content[$key]['#value'];
}
?>
vood002’s picture

In Drupal 6 CCK and Premium seem unable to mutually co-exist. I wasn't able to get anything else in this thread to work for me, so I wrote my own little hack to the Contemplate module.

I realize this is probably a terrible way to go about it...and if anyone has better ideas I'd love to hear them, but this is working for me so I figured I'd post it for anyone who is trying to get Premium to work on D6.

The workaround is pretty simple...in contemplate.module, within the call to hook_nodeapi:

Replace: (on like 180 in Contemplate 6.x.1.1)

        elseif (CONTEMPLATE_BODY_ENABLED & $template['flags'] && trim($template['body'])) { // only if there's content in the body field
		$node->body = contemplate_eval($template['body'], $node, $xml_elements); 
        }

With:

        elseif (CONTEMPLATE_BODY_ENABLED & $template['flags'] && trim($template['body'])) { // only if there's content in the body field
			if ($node->premium_access == ''){
			  $node->body = contemplate_eval($template['teaser'], $node, $xml_elements);
              $node->body.='<div class="premium-message">'. check_markup(variable_get('premium_message', t('Full text available to premium subscribers only')), variable_get('premium_format', FILTER_FORMAT_DEFAULT), FALSE) .'</div>';		
			}
			else{
			  $node->body = contemplate_eval($template['body'], $node, $xml_elements); 
			}          
        }

The workaround is very simple. If the Contemplate module is going to set $node->body to your templated output, it first checks if premium access is set. If it is not, it instead sets the $node->body equal to it's templated teaser output, adds the premium string, and outputs that instead.

If anyone has any tips on improving this code I'd love to hear them.

magpie5212’s picture

subscribing

geantbrun’s picture

I have the same problem (I add a form with nodeapi in a custom module and it gets lost in contemplate). Can we have a status on that problem? I suppose that many things have changed since nov.2006 (first message in this issue) but I must admit that (as newbie), reading all the posts did not help me much... Is a hack the only solution?

bomarmonk’s picture

I still don't understand why this module cannot render a node the way Drupal does by default. When you enable a template through this module, it automatically removes any links (books, fivestar, etc., .etc) that would be normally viewed with the node. I guess it's just one of the limitations here, and its been this way for over three years. Fixing this would greatly improve the usability of this module.