diff --git includes/common.inc includes/common.inc
index f5508c5..bad8984 100644
--- includes/common.inc
+++ includes/common.inc
@@ -3263,7 +3263,12 @@ function drupal_alter($type, &$data) {
function drupal_get_page($content = NULL) {
// Initialize page array with defaults. @see hook_elements() - 'page' element.
$page = element_info('page');
- $page['content'] = is_array($content) ? $content : array('main' => array('#markup' => $content));
+ system_set_content_block($content);
+
+ // UNCOMMENT this if you try this patch without re-installation. Then
+ // put the main content block into the content region and then comment
+ // this out again (or your content will be printed twice).
+ // $page['content'] = is_array($content) ? $content : array('main' => array('#markup' => $content));
return $page;
}
diff --git includes/theme.inc includes/theme.inc
index a5cd31d..7fd2125 100644
--- includes/theme.inc
+++ includes/theme.inc
@@ -2035,16 +2035,20 @@ function template_preprocess_node(&$variables) {
*/
function template_preprocess_block(&$variables) {
static $block_counter = array();
- $variables['block'] = $variables['block']['#block'];
+ $block = $variables['block'] = $variables['block']['#block'];
// All blocks get an independent counter for each region.
- if (!isset($block_counter[$variables['block']->region])) {
- $block_counter[$variables['block']->region] = 1;
+ if (!isset($block_counter[$block->region])) {
+ $block_counter[$block->region] = 1;
}
// Same with zebra striping.
- $variables['block_zebra'] = ($block_counter[$variables['block']->region] % 2) ? 'odd' : 'even';
- $variables['block_id'] = $block_counter[$variables['block']->region]++;
+ $variables['block_zebra'] = ($block_counter[$block->region] % 2) ? 'odd' : 'even';
+ $variables['block_id'] = $block_counter[$block->region]++;
- $variables['template_files'][] = 'block-' . $variables['block']->region;
- $variables['template_files'][] = 'block-' . $variables['block']->module;
- $variables['template_files'][] = 'block-' . $variables['block']->module . '-' . $variables['block']->delta;
+ $variables['content'] = is_array($block->content) ? drupal_render($block->content) : $block->content;
+ $variables['subject'] = $block->subject;
+ $variables['id'] = 'block-' . $block->module . '-' . $block->delta;
+
+ $variables['template_files'][] = 'block-' . $block->region;
+ $variables['template_files'][] = 'block-' . $block->module;
+ $variables['template_files'][] = 'block-' . $block->module . '-' . $block->delta;
}
diff --git modules/system/block.tpl.php modules/system/block.tpl.php
index 412000b..1b20011 100644
--- modules/system/block.tpl.php
+++ modules/system/block.tpl.php
@@ -6,8 +6,9 @@
* Default theme implementation to display a block.
*
* Available variables:
- * - $block->subject: Block title.
- * - $block->content: Block content.
+ * - $subject: Block title.
+ * - $content: Block content.
+ * - $id: HTML ID property for the block, composed of the block's module and delta.
* - $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.
@@ -25,12 +26,12 @@
* @see template_preprocess_block()
*/
?>
-
-subject): ?>
-
subject ?>
+
diff --git modules/system/system.install modules/system/system.install
index 1667074..cd9f006 100644
--- modules/system/system.install
+++ modules/system/system.install
@@ -3263,6 +3263,15 @@ function system_update_7020() {
}
/**
+ * Enable the main content block.
+ */
+function system_update_7021() {
+ $ret = array();
+ db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'main', 'garland', 1, 0, 'content', '', -1);
+ return $ret;
+}
+
+/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
*/
diff --git modules/system/system.module modules/system/system.module
index 3cb93a6..3d4f1f5 100644
--- modules/system/system.module
+++ modules/system/system.module
@@ -881,6 +881,11 @@ function system_user_timezone(&$edit, &$form) {
* Implementation of hook_block_list().
*/
function system_block_list() {
+ $blocks['main'] = array(
+ 'info' => t('Main page content'),
+ // Cached elsewhere.
+ 'cache' => BLOCK_NO_CACHE,
+ );
$blocks['powered-by'] = array(
'info' => t('Powered by Drupal'),
'weight' => '10',
@@ -946,6 +951,10 @@ function system_block_save($delta = '', $edit = NULL) {
function system_block_view($delta = '') {
$block = array();
switch ($delta) {
+ case 'main':
+ $block['subject'] = NULL;
+ $block['content'] = system_set_content_block();
+ return $block;
case 'powered-by':
$image_path = 'misc/' . variable_get('drupal_badge_color', 'powered-blue') . '-' . variable_get('drupal_badge_size', '80x15') . '.png';
// Don't display a title.
@@ -965,6 +974,23 @@ function system_block_view($delta = '') {
}
/**
+ * Memory for the page content so that it can be put into a region as a block.
+ *
+ * Given the nature of the Drupal page handling, this will be called once with
+ * a string or array. We store that and return it later as the block is being
+ * displayed.
+ */
+function system_set_content_block($content = NULL) {
+ $content_block = &drupal_static(__FUNCTION__, NULL);
+ if (!empty($content)) {
+ $content_block = (is_array($content) ? $content : array('main' => array('#markup' => $content)));
+ }
+ else {
+ return $content_block;
+ }
+}
+
+/**
* Provide a single block on the administration overview page.
*
* @param $item
diff --git profiles/default/default.profile profiles/default/default.profile
index c069f38..724255b 100644
--- profiles/default/default.profile
+++ profiles/default/default.profile
@@ -91,7 +91,8 @@ function default_profile_task_list() {
*/
function default_profile_tasks(&$task, $url) {
- // Enable 4 standard blocks.
+ // Enable 5 standard blocks.
+ db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'main', 'garland', 1, 0, 'content', '', -1);
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1);
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'navigation', 'garland', 1, 0, 'left', '', -1);
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'management', 'garland', 1, 1, 'left', '', -1);
diff --git profiles/expert/expert.profile profiles/expert/expert.profile
index b7e71fc..a919c39 100644
--- profiles/expert/expert.profile
+++ profiles/expert/expert.profile
@@ -42,7 +42,8 @@ function expert_profile_task_list() {
* Perform any final installation tasks for this profile.
*/
function expert_profile_tasks(&$task, $url) {
- // Enable 3 standard blocks.
+ // Enable 4 standard blocks.
+ db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'main', 'garland', 1, 0, 'content', '', -1);
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1);
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'navigation', 'garland', 1, 0, 'left', '', -1);
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'management', 'garland', 1, 1, 'left', '', -1);
diff --git themes/garland/block.tpl.php themes/garland/block.tpl.php
index 9a0025c..7481d03 100644
--- themes/garland/block.tpl.php
+++ themes/garland/block.tpl.php
@@ -1,11 +1,11 @@
-
+
-subject)): ?>
-
subject ?>
+
+
-
content ?>
+