/ Published in: PHP
A per-region override.
ogt_blocks is ran for a region, if a region contains blocks, we search for a theme function named theme_region_regionname(). If exists, we run that, else we just return the concatenated blocks for that region.
ogt_blocks is ran for a region, if a region contains blocks, we search for a theme function named theme_region_regionname(). If exists, we run that, else we just return the concatenated blocks for that region.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Return a set of blocks available for the current user. * Add a per-region template override option */ function ogt_blocks($region) { $output = ''; if ($list = block_list($region)) { $function = 'region_'. $region; if ($theme_function = theme_get_function($function)) { $blocks = array($list); //leave the buidling to the dedicated function $output = call_user_func_array($theme_function, $blocks); } else { foreach ($list as $key => $block) { //Build the string ourselves. $output .= theme('block', $block); } } } // Add any content assigned to this region through drupal_set_content() calls. $output .= drupal_get_content($region); return $output; } /** * Template/theme for the region named "siteinfo" (footer) * * @return void **/ function ogt_region_siteinfo($blocks) { return _phptemplate_callback('region_siteinfo', array('blocks' => $blocks)); } //-- in a templatefile region_siteinfo.tpl.php, put something like this: <?php foreach ($blocks as $block => $block) : ?> <?php print theme('block', $block); ?> <?php endforeach; ?>