function block_page_build
block_page_build(&$page)
Implements hook_page_build().
Renders blocks into their regions.
File
- modules/block/block.module, line 256
- Controls the visual building blocks a page is constructed with.
Code
function block_page_build(&$page) { global $theme; // The theme system might not yet be initialized. We need $theme. drupal_theme_initialize(); // Fetch a list of regions for the current theme. $all_regions = system_region_list($theme); $item = menu_get_item(); if ($item['path'] != 'admin/structure/block/demo/' . $theme) { // Load all region content assigned via blocks. foreach (array_keys($all_regions) as $region) { // Assign blocks to region. if ($blocks = block_get_blocks_by_region($region)) { $page[$region] = $blocks; } } // Once we've finished attaching all blocks to the page, clear the static // cache to allow modules to alter the block list differently in different // contexts. For example, any code that triggers hook_page_build() more // than once in the same page request may need to alter the block list // differently each time, so that only certain parts of the page are // actually built. We do not clear the cache any earlier than this, though, // because it is used each time block_get_blocks_by_region() gets called // above. drupal_static_reset('block_list'); } else { // Append region description if we are rendering the regions demo page. $item = menu_get_item(); if ($item['path'] == 'admin/structure/block/demo/' . $theme) { $visible_regions = array_keys(system_region_list($theme, REGIONS_VISIBLE)); foreach ($visible_regions as $region) { $description = '<div class="block-region">' . $all_regions[$region] . '</div>'; $page[$region]['block_description'] = array( '#markup' => $description, '#weight' => 15, ); } $page['page_top']['backlink'] = array( '#type' => 'link', '#title' => t('Exit block region demonstration'), '#href' => 'admin/structure/block' . (variable_get('theme_default', 'bartik') == $theme ? '' : '/list/' . $theme), // Add the "overlay-restore" class to indicate this link should restore // the context in which the region demonstration page was opened. '#options' => array('attributes' => array('class' => array('block-demo-backlink', 'overlay-restore'))), '#weight' => -10, ); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!block!block.module/function/block_page_build/7.x