return array(

    'clf_header' => array(
      'template' => 'header',
      'arguments' => array('node' => $node),
      'path' => $path2,
    ),

...

In hook_theme, when returning, can I pass the current loaded node object as $node?

Thanks,

(Above code does not work as expected. The passed $node is NULL not the current loaded node object)

Comments

nevets’s picture

hook_theme define theme functions and the arguments they expect. While you can define static/fixed/default values, its up to the caller to passer in current values.

minghui.yu’s picture

From page.tpl.php, I need to call a few other custom templates (like test.tpl.php). In those custom templates, I find the node object is not available. I have to either load the node object (get arg(1)) over and over across many custom template or I need a way to pass the node object to those templates.

mahendra.sharma’s picture

yes u can,

in your calling u can do this like this: -
print theme('key for hook',$nodeOBject);

---------------------------------------
and in hook_theme :---

return array(

'clf_header' => array(
'template' => 'header',
'arguments' => array('nodeobject' => null,'myname'=> 'i love drupal'),
'path' => $path2,
),
--------------

in your tpl file u can do this :-

print_r($nodeobject);//wiil print node object
print_r($nodeobject);// will print "i love drupal"