I've been creating my own module that consist an array of blocks. I plan to print them using context as oppose programatically as I already have the module on use (no need to reinvent the wheel). However, whenever I use context to display a block on a region, it always display it on the highest part of html body tag. e.g.
<body>
block content rendered here...
as oppose to my custom region,
<div class="l-info-bar">
I want my block content rendered here...
I cleared the cache several times. Made sure that the context is set to display the block on info bar region.
Here's my code for reference.
function custom_module_block_info() {
$blocks = array();
$blocks['my_block_top_navigation'] = array(
'info' => t('Top Bar Navigation Menu'),
'cache' => DRUPAL_CACHE_GLOBAL,
);
$blocks['my_block_avatar'] = array(
'info' => t('Avatar'),
'cache' => DRUPAL_CACHE_GLOBAL,
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function custom_module_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'my_block_top_navigation':
$block['subject'] = '';
$block['content'] = _custom_module_block_top_navigation_content();
break;
case 'my_block_avatar':
$block['subject'] = '';
$block['content'] = _custom_module_block_avatar_content();
break;
}
return $block;
}
function _custom_module_block_top_navigation_content() {
lots of code here...
}
function _custom_module_block_avatar_content() {
lots of code here...
}
I'm guessing you have to prep your block so context can actually place it to certain region?
Update1: I forgot to mentioned that normal blocks works on context and normal block display (only my custom block doesn't work on normal way and context—which is why I though problem lies in my coding—not context module). I also tried printing the block through code and works perfectly but I don't want extra code I don't need because I have context on use.
Update 2: I also replaced the block content with print t('TEST') and still printing above body through normal means and context. Works well printing using code.