So I have several menu blocks in a region one my drupal 7 site. I need to wrap each of these menu blocks in a <section>
tag, but leave all other menu blocks unaffected. My thinking was to preprocess the region, check if the blocks were menu blocks, and as you can see, attempt to simply wrap the output in a section tag. Can someone PLEASE tell me what I'm doing wrong? This problem is killing me.
function mytheme_preprocess_region(&$vars){
//checks to see if we're in the correct region
if($vars['region'] == "footer-top"){
//loops through every block in our region
foreach($vars['elements'] as $key => $item){
$block_type = $item['#block']->module;
//if it's a menu block, wrap the output in section tag, this doesnt work
if($block_type == "menu_block"){
//$vars['elements']['menu_block_4']['#children'] = "<section>" . $item['#children'] . "</section>";
$vars['elements'][$key]['#children'] = "<section>" . $item['#children'] . "</section>";
}
}
}
}
look into block templating. the base block template is in modules/block/block.tpl.php. you can override base template for a specific block.
basically you just need to create a new block template file in your theme folder.
https://drupal.org/node/1089656