From 26fa7c730f878220a46478c47f6145f459f68688 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 16 Aug 2005 18:06:18 +0000 Subject: - Patch #16216 by nedjo: multiple block regions! --- includes/common.inc | 44 ++++++++++++++++++++++++++++++++++++++++++++ includes/theme.inc | 6 +++++- 2 files changed, 49 insertions(+), 1 deletion(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index c38743c54..c9b61d402 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -24,6 +24,50 @@ define('SAVED_UPDATED', 2); */ define('SAVED_DELETED', 3); +/** + * Set content for a specified region. + * + * @param $region + * Page region the content is assigned to. + * + * @param $data + * Content to be set. + */ +function drupal_set_content($region = null, $data = null) { + static $content = array(); + + if (!is_null($region) && !is_null($data)) { + $content[$region][] = $data; + } + return $content; +} + +/** + * Get assigned content. + * + * @param $region + * A specified region to fetch content for. If null, all regions will be returned. + * + * @param $delimiter + * Content to be inserted between exploded array elements. + */ +function drupal_get_content($region = null, $delimiter = ' ') { + $content = drupal_set_content(); + if (isset($region)) { + if (is_array($content[$region])) { + return implode ($delimiter, $content[$region]); + } + } + else { + foreach (array_keys($content) as $region) { + if (is_array($content[$region])) { + $content[$region] = implode ($delimiter, $content[$region]); + } + } + return $content; + } +} + /** * Set the breadcrumb trail for the current page. * diff --git a/includes/theme.inc b/includes/theme.inc index 559640e8c..edbd8d58c 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -798,7 +798,7 @@ function theme_box($title, $content, $region = 'main') { * * @param $block * An object populated with fields from the "blocks" database table - * ($block->module, $block->delta, $block->region, ...) and fields returned by + * ($block->module, $block->delta ...) and fields returned by * module_block('view') ($block->subject, $block->content, ...). * @return * A string containing the block output. @@ -945,6 +945,10 @@ function theme_blocks($region) { $output .= theme('block', $block); } } + + // Add any content assigned to this region through drupal_set_content() calls. + $output .= drupal_get_content($region); + return $output; } -- cgit v1.2.3