When a page request is made, theme system ask block system for returning list of blocks for each region. It does this when preparing the variables to be send to the page template (usually page.tpl.php). For example to gather the themed blocks for the left and right sidebars, Drupal executes the following:
$sidebar_left = theme('blocks', 'left');
$sidebar_right = theme('blocks', 'right');
// And any other regions exposed by hook_regions().
theme('blocks') is actually a call to theme_blocks().
Here’s what theme_blocks() actually does:
function theme_blocks($region) {
$output = '';
if ($list = block_list($region)) {
foreach ($list as $key => $block) {
$output .= theme('block', $block);
}
}
return $output;
}
In the above code snippet, we just iterate through each block for the given region and execute a theme function call for each block. Finally, we return all the themed blocks for that
region back to the calling code.
- Kiran's blog
- 988 reads













Added to DrupalSightings.com
Post new comment