passing arguments from preprocess_page to block & node - drupal 6
Is there a way to pass some $variables to block & node from function like template_page_preproceess on drupal 6?
$vars should already be available to node.tpl.php (if $vars doesn't work for you, use $variables). To add another variable to the $vars, add the following to template.php:
function yourtheme_preprocess_node(&$vars, $hook) {
$vars['yourvariable'] = "your variable content";
}
And then in node.tpl.php you can output the contents of the variable where you want by adding this:
<?php if ($yourvariable): ?>
<?php print $yourvariable ?>
<?php endif; ?>
Don't forget to flush the theme cache if you're not seeing your new item.
精彩评论