Passing variables to a theme from a custom module I have a custom module which initiates the theme hook - passing the $node object as an argument:

theme('my_widget', array($node)); 


function my_module_theme() {
  return array(
    'my_widget' => array(
      'template' => 'my_widget',
      'variables' => array('node' => array($node)),
    ),
  );
}


However, in the 'my-widget' template file, I need to pick up the $node variable. But doing a dpm() on $node returns Null.. - think I may be setting the variable incorrectly, but not sure what's going on. Cheers
The correct code is the following one.


Theme call  

theme('my_widget', array('node' =&gt; $node)); 

Theme declaration  

function my_module_theme() {
  return array(
    'my_widget' =&gt; array(
      'template' =&gt; 'my_widget',
      // This array contains the default values.
      // You should not use a PHP variable.
      'variables' =&gt; array('node' =&gt; NULL),
    ),
  );
}