Drupal has hooks, one of then is called hook_node_view which allows you to inject variables into your node templates. In order to actually modify the node with the content variables… done like so:
1 |
$node->content['variable'] = 'new var'; |
You need to actually return the $node variable from the hook function.
1 2 3 4 5 6 7 8 9 |
//mymodule.module function mymodule_node_view($node, $view_mode, $langcod){ if($node->type == 'content_type'){ $node->content['variable'] = 'new var'; return $node; } } |
You can then use the variable in your node template.
1 2 |
//node--content-type.tpl.php print $content['variable']; |