Thursday, September 22, 2011

Making additional variables available to your templates

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

?>


Example 2:
<?php
function _phptemplate_variables($hook, $vars) {
switch ($hook) {
case 'page':
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '') {
$vars['content_is_node'] = TRUE;
}
break;
}
return $vars;
}
?>

No comments:

Post a Comment