diff --git includes/common.inc includes/common.inc index 703d369..b535b75 100644 --- includes/common.inc +++ includes/common.inc @@ -3248,7 +3248,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 3e75e79..5165d66 100644 --- includes/theme.inc +++ includes/theme.inc @@ -2053,6 +2053,10 @@ function template_preprocess_block(&$variables) { $variables['block_zebra'] = ($block_counter[$variables['block']->region] % 2) ? 'odd' : 'even'; $variables['block_id'] = $block_counter[$variables['block']->region]++; + $variables['block']->content = is_array($variables['block']->content) + ? drupal_render($variables['block']->content) + : $variables['block']->content; + $variables['template_files'][] = 'block-' . $variables['block']->region; $variables['template_files'][] = 'block-' . $variables['block']->module; $variables['template_files'][] = 'block-' . $variables['block']->module . '-' . $variables['block']->delta; diff --git modules/system/system.install modules/system/system.install index 47cfd09..8e536f8 100644 --- modules/system/system.install +++ modules/system/system.install @@ -3244,6 +3244,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 da1a8f5..b6c00f1 100644 --- modules/system/system.module +++ modules/system/system.module @@ -889,6 +889,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', @@ -954,6 +959,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. @@ -973,6 +982,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);