Currently regions named "left" and "right" get special treatment in Drupal's template_preprocess_page() function: if the $show_blocks variable is set to FALSE, then those 2 regions are not rendered.
Panels (and possible other modules) use the $show_blocks "trick" to make the sidebars disappear on Panel pages by calling theme('page', $content, FALSE).
I would very much like to rename the $left and $right variables to match the RTL-friendly div names that page.tpl.php already has, but I don't want to break this somewhat critical Drupal behavior. It is, unfortunately, complicated by the fact that this "don't generate blocks for left/right regions" behavior is baked into template_preprocess_page() and there is no obvious way to alter that; the $regions are retrieved directly from system_region_list() and then immediately conditionally rendered using theme_blocks(). But I have a plan… :-D
- Use zen_theme() to insert a preprocess function before template_preprocess_page(). Let's call it zen_show_blocks_discovery() or zen_show_blocks_hack().
- Define a theme_blocks implementation that has an additional $shows_blocks parameter.
function zen_blocks($region, $show_blocks = NULL) {} - Inside
zen_show_blocks_discovery($vars), pass the $vars['show_blocks'] value to our theme_blocks implementation.theme('blocks', NULL, $vars['show_blocks']); - When our theme_hooks implementation sees a non-NULL value for $show_blocks, store that value in a static variable for later use.
template_preprocess_pageis called afterzen_show_blocks_discovery($vars)and its code will no longer find a 'left' or 'right' region. So it will attempt to render all regions by callingtheme('blocks', $region).- Our theme_blocks implementation will now receive a request to render all regions, but it also has a copy of the $shows_blocks value. So it can decide on its own which regions to render or not and we have zen_blocks skip the rendering of the sidebar_first and sidebar_second regions if $shows_blocks is FALSE.
- Finally, we'll have to regenerate $layout and body classes in zen_preprocess_page().
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | sidebar-vars-621798-1.diff | 8.92 KB | johnalbin |
Comments
Comment #1
johnalbinFixed!