summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnAlbin2009-10-15 15:34:18 +0000
committerJohnAlbin2009-10-15 15:34:18 +0000
commit94f892798029746150f79f55465f575e5fdd462b (patch)
treeb2829583edcad1361c42acfbf60092147877f548
parent3c141af0d5d15915e9f1f1ba589f7f23be8f17e4 (diff)
Add region.tpl.php template
-rw-r--r--CHANGELOG.txt3
-rw-r--r--template.php48
-rw-r--r--templates/region.tpl.php32
-rw-r--r--zen-internals/template.theme-registry.inc14
4 files changed, 95 insertions, 2 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 5a36cdb..c440de2 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -2,7 +2,8 @@
Zen 6.x-2.x-dev, xxxx-xx-xx (development release)
------------------------
-- * Render $edit_links_array in zen_process_block
+- Add region.tpl.php template
+- Render $edit_links_array in zen_process_block
- #546858: Add THEME_process_HOOK functions to Zen
- #317417 by JohnAlbin and quicksketch: Fix off-line maintenance page since drupal_get_path('theme', 'zen') won't work
- #549798 by caroltron: page-backgrounds.css missing from .info file
diff --git a/template.php b/template.php
index 647593c..9924d44 100644
--- a/template.php
+++ b/template.php
@@ -98,6 +98,32 @@ function zen_menu_local_tasks() {
return $output;
}
+/**
+ * Return a set of blocks available for the current user.
+ *
+ * @param $region
+ * Which set of blocks to retrieve.
+ * @return
+ * A string containing the themed blocks for this region.
+ */
+function zen_blocks($region) {
+ $output = '';
+
+ if ($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);
+
+ $elements['#children'] = $output;
+ $elements['#region'] = $region;
+
+ return $output ? theme('region', $elements) : '';
+}
/**
* Override or insert variables into the page templates.
@@ -259,6 +285,28 @@ function zen_preprocess_comment(&$vars, $hook) {
}
/**
+ * Preprocess variables for region.tpl.php
+ *
+ * Prepare the values passed to the theme_region function to be passed into a
+ * pluggable template engine. Uses the region name to generate a template file
+ * suggestions. If none are found, the default region.tpl.php is used.
+ *
+ * @see region.tpl.php
+ */
+function zen_preprocess_region(&$vars, $hook) {
+ // Create the $content variable that templates expect.
+ $vars['content'] = $vars['elements']['#children'];
+ $vars['region'] = $vars['elements']['#region'];
+
+ $region = 'region-' . str_replace('_', '-', $vars['region']);
+ $vars['classes_array'] = array('region', $region);
+ if ($vars['region'] == 'navbar') {
+ $vars['classes_array'][] = 'clearfix';
+ }
+ $vars['template_files'][] = $region;
+}
+
+/**
* Override or insert variables into the block templates.
*
* @param $vars
diff --git a/templates/region.tpl.php b/templates/region.tpl.php
new file mode 100644
index 0000000..8d10e78
--- /dev/null
+++ b/templates/region.tpl.php
@@ -0,0 +1,32 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Default theme implementation to display a region.
+ *
+ * Available variables:
+ * - $content: The content for this region, typically blocks.
+ * - $classes: String of classes that can be used to style contextually through
+ * CSS. It can be manipulated through the variable $classes_array from
+ * preprocess functions. The default values can be one or more of the following:
+ * - region: The current template type, i.e., "theming hook".
+ * - region-[name]: The name of the region with underscores replaced with
+ * dashes. For example, the page_top region would have a region-page-top class.
+ * - $region: The name of the region variable as defined in the theme's .info file.
+ *
+ * Helper variables:
+ * - $classes_array: Array of html class attribute values. It is flattened
+ * into a string within the variable $classes.
+ * - $is_admin: Flags true when the current user is an administrator.
+ * - $is_front: Flags true when presented in the front page.
+ * - $logged_in: Flags true when the current user is a logged-in member.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_region()
+ * @see template_process()
+ */
+?>
+<div class="<?php print $classes; ?>">
+ <?php print $content; ?>
+</div>
diff --git a/zen-internals/template.theme-registry.inc b/zen-internals/template.theme-registry.inc
index a33c086..8fa0c1c 100644
--- a/zen-internals/template.theme-registry.inc
+++ b/zen-internals/template.theme-registry.inc
@@ -60,7 +60,19 @@ function _zen_theme(&$existing, $type, $theme, $path) {
}
}
- // Return nothing.
+ // The base theme registers region.tpl.php
+ if ($theme == 'zen') {
+ return array(
+ 'region' => array(
+ 'arguments' => array('elements' => NULL),
+ //'pattern' => 'region_',
+ 'path' => drupal_get_path('theme', 'zen') . '/templates',
+ 'template' => 'region',
+ ),
+ );
+ }
+
+ // Else return nothing.
return array();
}