diff options
author | Dries Buytaert <dries@buytaert.net> | 2005-08-16 18:06:18 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2005-08-16 18:06:18 +0000 |
commit | 26fa7c730f878220a46478c47f6145f459f68688 (patch) | |
tree | 16c0ce7230150b0f8cee0f4d360c9756f8746764 /themes/engines/phptemplate | |
parent | 6ef678e4475c6e500b371be6f5a9a66115686480 (diff) | |
download | brdo-26fa7c730f878220a46478c47f6145f459f68688.tar.gz brdo-26fa7c730f878220a46478c47f6145f459f68688.tar.bz2 |
- Patch #16216 by nedjo: multiple block regions!
Diffstat (limited to 'themes/engines/phptemplate')
-rw-r--r-- | themes/engines/phptemplate/phptemplate.engine | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/themes/engines/phptemplate/phptemplate.engine b/themes/engines/phptemplate/phptemplate.engine index dde0ae2f7..366420fdd 100644 --- a/themes/engines/phptemplate/phptemplate.engine +++ b/themes/engines/phptemplate/phptemplate.engine @@ -18,6 +18,22 @@ function phptemplate_templates($directory = 'themes') { } /** + * Declare the available regions implemented by this engine. + * + * @return + * An array of regions. The first array element will be used as the default region for themes. + */ +function phptemplate_regions() { + return array( + 'left' => t('left sidebar'), + 'right' => t('right sidebar'), + 'content' => t('content'), + 'header' => t('header'), + 'footer' => t('footer') + ); +} + +/** * Execute a template engine call. * * Each call to the template engine has two parts. Namely preparing @@ -68,6 +84,7 @@ function _phptemplate_callback($hook, $variables = array(), $file = null) { * A sequential array of variables passed to the theme function. */ function _phptemplate_default_variables($hook, $variables) { + global $theme; static $count = array(); $count[$hook] = is_int($count[$hook]) ? $count[$hook] : 1; $variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even'; @@ -79,7 +96,18 @@ function _phptemplate_default_variables($hook, $variables) { $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'))) { + $variables[$region] .= theme('blocks', $region); + } + } + } // Tell all templates where they are located. $variables['directory'] = path_to_theme(); @@ -128,7 +156,7 @@ function phptemplate_page($content) { $layout = 'none'; global $sidebar_indicator; /** - * Sidebar_indicator tells the block counting code to count sidebars seperately. + * Sidebar_indicator tells the block counting code to count sidebars separately. */ $sidebar_indicator = 'left'; $sidebar_left = theme('blocks', 'left'); @@ -158,7 +186,7 @@ function phptemplate_page($content) { 'breadcrumb' => theme('breadcrumb', drupal_get_breadcrumb()), 'closure' => theme('closure'), 'content' => '<!-- begin content -->' . $content . '<!-- end content -->', - 'footer_message' => variable_get('site_footer', FALSE), + 'footer_message' => variable_get('site_footer', FALSE) . "\n" . theme('blocks', 'footer'), 'head' => drupal_get_html_head(), 'head_title' => implode(' | ', $head_title), 'help' => theme('help'), |