hi,
I need to modify the node content Array before it is rendered into html. For this reason I cannot use the $content variable in my node template. I'm looking for it in template.php file, but I cannot find it.
thanks
hi,
I need to modify the node content Array before it is rendered into html. For this reason I cannot use the $content variable in my node template. I'm looking for it in template.php file, but I cannot find it.
thanks
Original function that generates variables available to the node is: http://api.drupal.org/api/function/template_preprocess_node/6
You can modify template variables by implementing your own node preprocess function inside template.php that will execute after original function therefore allowing you to add your own variables:
function phptemplate_preprocess_node(&$vars, $hook) {
// Here you can add your custom variable...
$vars['myContent'] = "something";
}
AFAIK, you can not access the unrendered node content array from within a theme, as the theme processing occurs to late in the processing cycle (i.e. the content array will already be rendered as you observed).
The standard way to access and modify the node content array before it gets rendered would be to implement hook_nodeapi()
within a custom module, reacting to the 'view' operation. This gets invoked after the content array has been assembled, but before it gets rendered, allowing you to adjust it at will.
Be aware that other modules might do this as well - if that is the case and you want to adjust values provided by other modules, the call order of the modules becomes relevant and you might need to adjust your modules weight to ensure it gets called after the others.