How Blocks are Themed in Drupal

0
Your rating: None

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.

 #  

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Cumulus Tag Cloud

Kiran Says

SEO Architect,SEO Specialist reflect my values.

By enduring black hat methods the SEO industry is setting itself up for washout and sleepwalking into oblivion.

Jobs in India