use phptemplate variables

Making additional variables available to your templates

Examples from this forum discussion. The $hook refers to the area the variable is to be used in (e.g. for comment.tpl.php, it would be "comment").

This function needs to be defined in a template.php file, which is placed inside the template directory (for instance : themes/box_cleanslate/template.php)

<?php
function  _phptemplate_variables($hook, $vars) {
   switch(
$hook) {
     case
'comment' :
       
$vars['newvar'] = 'new variable';
       
$vars['title'] = 'new title';
        break;
   }
   return
$vars;
}
?>

The output of this function is merged with the variables returned from phptemplate_comment, so you can easily adjust whichever variables you feel necessary.

Your comment.tpl.php file will now have a new variable available in it
called $newvar. Similarly the $title variable will be overridden with the value specified in
the function.

Syndicate content
 
 

Drupal is a registered trademark of Dries Buytaert.