开发者

passing arguments from preprocess_page to block & node - drupal 6

开发者_StackOverflow社区

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜