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

  1. 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().
  2. Define a theme_blocks implementation that has an additional $shows_blocks parameter. function zen_blocks($region, $show_blocks = NULL) {}
  3. Inside zen_show_blocks_discovery($vars), pass the $vars['show_blocks'] value to our theme_blocks implementation. theme('blocks', NULL, $vars['show_blocks']);
  4. When our theme_hooks implementation sees a non-NULL value for $show_blocks, store that value in a static variable for later use.
  5. template_preprocess_page is called after zen_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 calling theme('blocks', $region).
  6. 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.
  7. Finally, we'll have to regenerate $layout and body classes in zen_preprocess_page().
CommentFileSizeAuthor
#1 sidebar-vars-621798-1.diff8.92 KBjohnalbin

Comments

johnalbin’s picture

Status: Active » Fixed
StatusFileSize
new8.92 KB

Fixed!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.