diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 955717323e10c684eede33ffa3590eab7ec6eba1..5999f61f54a88c6880def768b6d62a3860a91ac6 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -2,6 +2,7 @@ Zen 6.x-2.x-dev, xxxx-xx-xx (development release) ------------------------ +- #621798: Change sidebar variables to be RTL friendly and $shows_blocks compatible - #547696: Update node.tpl to use ideas from D7 - #620794: Update block.tpl to use ideas from D7 - #548994: Update comment.tpl and comment-wrapper.tpl to use ideas from D7 diff --git a/STARTERKIT/STARTERKIT.info.txt b/STARTERKIT/STARTERKIT.info.txt index fd56732354c869061c71f0343d08f57c6380a4ef..eb6e283c1fb367a15978a800dda1f403f9fcb5e9 100644 --- a/STARTERKIT/STARTERKIT.info.txt +++ b/STARTERKIT/STARTERKIT.info.txt @@ -60,8 +60,8 @@ conditional-stylesheets[if lte IE 6][all][] = css/ie6.css ; To add a new region, copy Zen's page.tpl.php to your sub-theme's directory, ; add a line line to this file, and then add the new variable to your ; page.tpl.php template. -regions[left] = first sidebar -regions[right] = second sidebar +regions[sidebar_first] = first sidebar +regions[sidebar_second] = second sidebar regions[navbar] = navigation bar regions[content_top] = content top regions[content_bottom] = content bottom diff --git a/template.php b/template.php index cf901d33611e97627b620748349438b5b670ba46..51f6a32c21b3b5ef5b898c942daa44b7606df43a 100644 --- a/template.php +++ b/template.php @@ -103,26 +103,61 @@ function zen_menu_local_tasks() { * * @param $region * Which set of blocks to retrieve. + * @param $show_blocks + * A boolean to determine whether to render sidebar regions or not. Should be + * the same value as passed to theme_page. * @return * A string containing the themed blocks for this region. + * + * @see zen_show_blocks_discovery() */ -function zen_blocks($region) { - $output = ''; +function zen_blocks($region, $show_blocks = NULL) { + // Since Drupal 6 doesn't pass $show_blocks to theme_blocks, we manually call + // theme('blocks', NULL, $show_blocks) so that this function can remember the + // value on later calls. + static $render_sidebars = TRUE; + if (!is_null($show_blocks)) { + $render_sidebars = $show_blocks; + } - if ($list = block_list($region)) { - foreach ($list as $key => $block) { - // $key == module_delta - $output .= theme('block', $block); + // If zen_blocks was called with a NULL region, its likely we were just + // setting the $render_sidebars static variable. + if ($region) { + $output = ''; + + // If $renders_sidebars is FALSE, don't render any region whose name begins + // with "sidebar_". + if (($render_sidebars || (strpos($region, 'sidebar_') !== 0)) && ($list = block_list($region))) { + foreach ($list as $key => $block) { + // $key == module_delta + $output .= theme('block', $block); + } } - } - // Add any content assigned to this region through drupal_set_content() calls. - $output .= drupal_get_content($region); + // Add any content assigned to this region through drupal_set_content() calls. + $output .= drupal_get_content($region); - $elements['#children'] = $output; - $elements['#region'] = $region; + $elements['#children'] = $output; + $elements['#region'] = $region; - return $output ? theme('region', $elements) : ''; + return $output ? theme('region', $elements) : ''; + } +} + +/** + * Examine the $show_blocks variable before template_preprocess_page() is called. + * + * @param $vars + * An array of variables to pass to the page template. + * + * @see zen_blocks() + */ +function zen_show_blocks_discovery(&$vars) { + if ($vars['show_blocks'] == FALSE) { + // Allow zen_blocks() to statically cache the $show_blocks variable. A TRUE + // value is assumed, so we only need to override when $show_blocks is FALSE. + theme('blocks', NULL, FALSE); + } } /** @@ -195,15 +230,30 @@ function zen_preprocess_page(&$vars, $hook) { if (theme_get_setting('zen_wireframes')) { $vars['classes_array'][] = 'with-wireframes'; // Optionally add the wireframes style. } - // Add new sidebar classes in addition to Drupal core's sidebar-* classes. - // This provides some backwards compatibility with Zen 6.x-1.x themes. - if ($vars['layout'] != 'both') { - $new_layout = ($vars['layout'] == 'left') ? 'first' : 'second'; - if (array_search('sidebar-' . $vars['layout'], $vars['classes_array'])) { - $vars['classes_array'][] = 'sidebar-' . $new_layout; + // We need to re-do the $layout and body classes because + // template_preprocess_page() assumes sidebars are named 'left' and 'right'. + $vars['layout'] = 'none'; + if (!empty($vars['sidebar_first'])) { + $vars['layout'] = 'first'; + } + if (!empty($vars['sidebar_second'])) { + $vars['layout'] = ($vars['layout'] == 'first') ? 'both' : 'second'; + } + // If the layout is 'none', then template_preprocess_page() will already have + // set a 'no-sidebars' class since it won't find a 'left' or 'right' sidebar. + if ($vars['layout'] != 'none') { + // Remove the incorrect 'no-sidebars' class. + if ($index = array_search('no-sidebars', $vars['classes_array'])) { + unset($vars['classes_array'][$index]); + } + // Set the proper layout body classes. + if ($vars['layout'] == 'both') { + $vars['classes_array'][] = 'two-sidebars'; + } + else { + $vars['classes_array'][] = 'one-sidebar'; + $vars['classes_array'][] = 'sidebar-' . $vars['layout']; } - // Replace core's $layout variable with our naming of sidebars. - $vars['layout'] = $new_layout; } } diff --git a/templates/maintenance-page.tpl.php b/templates/maintenance-page.tpl.php index 7d34b39b355a3aa7b265f32f2daf8478498867f4..ee4774e9c475f347a16fe79c0015e6965ef94660 100644 --- a/templates/maintenance-page.tpl.php +++ b/templates/maintenance-page.tpl.php @@ -88,15 +88,15 @@ - + - + diff --git a/templates/page.tpl.php b/templates/page.tpl.php index 02a245c4ead2fa69c0a8b522b4184c48d346af41..910c9667c56731730237a7df5c0798f87c685d32 100644 --- a/templates/page.tpl.php +++ b/templates/page.tpl.php @@ -72,8 +72,8 @@ * - $help: Dynamic help text, mostly for admin pages. * - $content: The main content of the current page. * - $feed_icons: A string of all feed icons for the current page. - * - $left: The HTML for the first sidebar. - * - $right: The HTML for the second sidebar. + * - $sidebar_first: The HTML for the first sidebar. + * - $sidebar_second: The HTML for the second sidebar. * * Footer/closing data: * - $footer_message: The footer message as defined in the admin settings. @@ -195,15 +195,15 @@ - + - + diff --git a/zen-internals/template.theme-registry.inc b/zen-internals/template.theme-registry.inc index ea7a86052c792de13afd341c256d2eda75823fb7..8cb45fece094a978f5c0415f2466b708f154062d 100644 --- a/zen-internals/template.theme-registry.inc +++ b/zen-internals/template.theme-registry.inc @@ -60,8 +60,12 @@ function _zen_theme(&$existing, $type, $theme, $path) { } } - // The base theme registers region.tpl.php + // Manipulations only to be done by the base theme. if ($theme == 'zen') { + // Insert zen_show_blocks_discovery() before template_preprocess_page(). + $existing['page']['preprocess functions'] = array_merge(array('zen_show_blocks_discovery'), $existing['page']['preprocess functions']); + + // The base theme registers region.tpl.php. return array( 'region' => array( 'arguments' => array('elements' => NULL), diff --git a/zen.info b/zen.info index 84143f44e8d6d1bfcf201da9e1250c4020a5a079..201edebab0d993215a9f389dce5a54f155ffd3a0 100644 --- a/zen.info +++ b/zen.info @@ -8,8 +8,8 @@ screenshot = zen-internals/screenshot.png core = 6.x engine = phptemplate -regions[left] = first sidebar -regions[right] = second sidebar +regions[sidebar_first] = first sidebar +regions[sidebar_second] = second sidebar regions[navbar] = navigation bar regions[content_top] = content top regions[content_bottom] = content bottom