diff --git modules/block/block.module modules/block/block.module index c523804..efc908c 100644 --- modules/block/block.module +++ modules/block/block.module @@ -93,7 +93,7 @@ function block_help($path, $arg) { function block_theme() { return array( 'block' => array( - 'arguments' => array('block' => NULL), + 'arguments' => array('elements' => NULL), 'template' => 'block', ), 'block_admin_display_form' => array( @@ -244,14 +244,17 @@ function block_page_alter($page) { if (!empty($page['#show_blocks']) || ($region != 'left' && $region != 'right')) { // Assign blocks to region. if ($blocks = block_get_blocks_by_region($region)) { - $page[$region]['blocks'] = $blocks; + $page[$region] = $blocks; } // Append region description if we are rendering the block admin page. $item = menu_get_item(); if ($item['path'] == 'admin/build/block') { $description = '
' . $regions[$region] . '
'; - $page[$region]['blocks']['block_description'] = array('#markup' => $description); + $page[$region]['block_description'] = array( + '#markup' => $description, + '#weight' => 15, + ); } } } @@ -268,8 +271,10 @@ function block_get_blocks_by_region($region) { $build = array(); if ($list = block_list($region)) { foreach ($list as $key => $block) { - $build[$key] = array( - '#theme' => 'block', + $build[$key] = $block->content; + unset($block->content); + $build[$key] += array( + '#theme_wrapper' => 'block', '#block' => $block, '#weight' => ++$weight, ); @@ -683,6 +688,9 @@ function _block_render_blocks($region_blocks) { } } if (isset($block->content) && $block->content) { + // Normalize to the drupal_render() structure. + $block->content = is_string($block->content) ? array('#markup' => $block->content) : $block->content; + // Override default block title if a custom display title is present. if ($block->title) { // Check plain here to allow module generated titles to keep any markup. @@ -777,7 +785,7 @@ function block_flush_caches() { */ function template_preprocess_block(&$variables) { $block_counter = &drupal_static(__FUNCTION__, array()); - $variables['block'] = $variables['block']['#block']; + $variables['block'] = $variables['elements']['#block']; // All blocks get an independent counter for each region. if (!isset($block_counter[$variables['block']->region])) { $block_counter[$variables['block']->region] = 1; @@ -786,10 +794,8 @@ function template_preprocess_block(&$variables) { $variables['block_zebra'] = ($block_counter[$variables['block']->region] % 2) ? 'odd' : 'even'; $variables['block_id'] = $block_counter[$variables['block']->region]++; - if (is_array($variables['block']->content)) { - // Render the block contents if it is not already rendered. - $variables['block']->content = drupal_render($variables['block']->content); - } + // Create the $content variable that templates expect. + $variables['content'] = $variables['elements']['#children']; $variables['classes_array'][] = 'block-' . $variables['block']->module; diff --git modules/block/block.tpl.php modules/block/block.tpl.php index 5284912..11d6cd6 100644 --- modules/block/block.tpl.php +++ modules/block/block.tpl.php @@ -7,7 +7,7 @@ * * Available variables: * - $block->subject: Block title. - * - $block->content: Block content. + * - $content: Block content. * - $block->module: Module that generated the block. * - $block->delta: An ID for the block, unique within each module. * - $block->region: The block region embedding the current block. @@ -41,6 +41,6 @@
- content ?> +
diff --git themes/garland/block.tpl.php themes/garland/block.tpl.php index 6e13ff8..e0dec6f 100644 --- themes/garland/block.tpl.php +++ themes/garland/block.tpl.php @@ -7,5 +7,5 @@

subject ?>

-
content ?>
+