tags:

views:

30

answers:

2

I have a list of node ids and I want to display the 'page' view of each one. For various reasons, I don't want to do this with views, and don't think I should need a module. Just an API call to theme('node'). Something like:

$nids = array(3,4,5);
foreach ($nids as $nid) {
    $node = node_load($nid);
    $result .= theme('node', $node);
}

but I'm not getting back the full page view of the node. I added this to my node-[type].tpl.php file:

if ($page) print "PAGE MODE ";
else print "NOT PAGE ";
if ($teaser) print "TEASER MODE ";
else print "NOT TEASER ";

and got:

NOT PAGE NOT TEASER

I seem to be in some kind of limbo. I suspect there's an argument that I add to the theme function, but the terms are all so general (theme, teaser, page, node), I'm having trouble with my google-fu.

A: 

There it is! http://api.drupal.org/api/function/theme_node

I needed theme('node', $node, false, true). (Although my $content variable still isn't getting fully populated. Hmm..)

sprugman
+1  A: 

try node_view() http://api.drupal.org/api/function/node_view/6

barraponto
Thanks! Any idea why $content doesn't get populated with the theme('node') approach?
sprugman
node_view() runs drupal_render(), maybe that's why.
barraponto