How can I print a teaser from a specific nid? It’s driving me crazy.
I tried this:
$teaser = TRUE;
$page = FALSE;
$nid = 20;
print node_view(node_load(array('nid' => $nid)), $teaser, $page, FALSE);
but the only output is ‘Array’.
I also tried this:
$node = node_load(20);
$teaser_content = $node->body['und']['0']['summary'];
print $teaser_content;
But this is only giving me the summary of the node, not the teaser specified with <!--break-->.
In Drupal 7 there is no
$teaserargument to thenode_view()function, instead there is a$view_modeargument which takes a string (usuallyteaserorfull, the default isfull). The code you’re currently using would work perfectly for Drupal 6 though.This code will work for Drupal 7: