Hi! I'm currently developing a theme for a newspaper site and want to use the teaser field as preamble in full node view. The trouble is that the $node->teaser field is missing in my template file (node-story.tpl.php). Checking the "Dev render" tab the teaser value is set correctly. Preprocess functions are: template_preprocess + template_preprocess_node + content_preprocess_node + nodereference_preprocess_node + fieldgroup_preprocess_node + views_preprocess_node + zen_preprocess_node. Can't see that any of these unsets the teaser value. Any ideas?

Found the source of this "error" in node.module line 1010:

  $content = drupal_render($node->content);
  if ($teaser) {
    $node->teaser = $content;
    unset($node->body);
  }
  else {
    $node->body = $content;
    unset($node->teaser);
  }

Not sure I like this, but can't do anything about it without hacking core. Could fetch the node again with node_load, ugly as hell but could work.

Comments

gnucifer’s picture

Code:

$teaser_node = node_build_content(node_load($node->nid), TRUE));
print $teaser_node->teaser;

Works, but it's not a good solution. If anyone knows a better way of achieving this please let me know!

Summitt Dweller’s picture

I just encountered your post as I was seeing the same symptoms in my site. Thanks for the suggestion.

FYI... There are one too many ")" in the code above. First line of code should read:

$teaser_node = node_build_content(node_load($node->nid), TRUE);

Any idea if this is intended behavior and if/when this changed recently in core?

frob’s picture

Did anything ever come of this? Did you try posting this as a bug?