I've included a CCK node at the top of my front page, above the listing of the latest nodes. To do so, I've put the following lines in page-front.tpl.php:

$nid = db_result(db_query("SELECT MAX(nid) FROM node WHERE type = 'fp_selection'"));
$node = node_load($nid);
print theme('node', $node);
print $content; 

This works fine, *except* that the node contains some node references, output in the node-fp_selection.tpl.php file (that is the template for this content type, since it's called 'fp_selection') with the line print $node_reference1[0][view]; . This works fine when the node is viewed directly, but when included in the front page as above it's empty. By including print_r($node_reference1) in the template I can see that when the node is viewed directly $node_reference1[0] contains [nid] and [view], but when included in my front page it contains only [nid]. How can I get around this - how can I access the view of the node reference when loading the node manually rather than on the node page itself?

Many thanks for any help,
Thomas

Comments

markus_petrux’s picture

Title: Nodereference title ([view] member of array) not visible when node loaded via node_load » How to render a node from a page template
Component: nodereference.module » General
Category: bug » support

Try using node_view() instead of theme('node').

Tom Ash’s picture

Status: Active » Fixed

Thanks, that works!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.