_phptemplate_default_variables
- Versions
- 4.7 – 5
_phptemplate_default_variables($hook, $variables)
Adds additional helper variables to all templates.
Counts how many times certain hooks have been called. Sidebar left / right are special cases.
Parameters
$hook The name of the theme function being executed.
$variables A sequential array of variables passed to the theme function.
Code
themes/engines/phptemplate/phptemplate.engine, line 94
<?php
function _phptemplate_default_variables($hook, $variables) {
global $theme, $sidebar_indicator;
static $count = array();
$count[$hook] = isset($count[$hook]) && is_int($count[$hook]) ? $count[$hook] : 1;
$variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';
$variables['id'] = $count[$hook]++;
if ($hook == 'block') {
$count['block_counter'][$sidebar_indicator] = isset($count['block_counter'][$sidebar_indicator]) && is_int($count['block_counter'][$sidebar_indicator]) ? $count['block_counter'][$sidebar_indicator] : 1;
$variables['block_zebra'] = ($count['block_counter'][$sidebar_indicator] % 2) ? 'odd' : 'even';
$variables['block_id'] = $count['block_counter'][$sidebar_indicator]++;
}
elseif ($hook == 'page') {
$regions = system_region_list($theme);
// Load all region content assigned via blocks.
foreach (array_keys($regions) as $region) {
// Skip blocks in this region that have already been loaded.
// This pre-loading is necessary because phptemplate uses variable names different from
// the region names, e.g., 'sidebar_left' instead of 'left'.
if (!in_array($region, array('left', 'right', 'footer'))) {
$normal_blocks = (isset($variables['regions'])) ? $variables['regions'][$region] : theme('blocks', $region);
isset($variables[$region]) ? $variables[$region] .= $normal_blocks : $variables[$region] = $normal_blocks;
}
}
}
// Tell all templates where they are located.
$variables['directory'] = path_to_theme();
$variables['is_front'] = drupal_is_front_page();
return $variables;
}
?>Login or register to post comments 
Dynamic Calls
It would be very nice if the places in the standard Drupal installation where this function would be dynamically called were noted. Because of Drupal's nature, most of the important function calls are dynamic and so just noting where the function is called does not give the documentation's reader a full understanding of its importance