Hello,

I use $variables or $vars in one of my node without using the function _preprocess_node. Is this possible?

Example (in node-trial.tpl.php):
$vars['trial'] = 10;
print $trial;

Yet the result is NULL ...

Thank you in advance for your help!

Comments

nevets’s picture

Within node.tpl.php files using $vars ($variable) does not really make sense. Using best practices you should use hook_preprocess_node. If you are going to set variables in a node.tpl.php file you would just use $trial = 10;.

Clément’s picture

Thank you for your reply

I can not really go through with hook_preprocess_node because in my node I support multiple nodes with node_load() to retrieve information from certain labels.
If I wanted to use the function, it seems to me that I should re-charge my knots will not terrible perfomance point of view. At least I can send information from node_trial.tpl.php to hook_preprocess_node?

The example I gave was simplified but I think I'll just do like this to get my value:
print $vars['trial'];