I have run into an issue while using multiple versions of Context. The function blocks_get_blocks_by_region does not print any blocks when using context. If I move a block into the region via the normal blocks admin page the blocks print correctly, but if I use context to manage the blocks nothing gets pulled in. Is there a different function I should be using?

Comments

tekante’s picture

Category: bug » support
Status: Active » Fixed

Yes, if you want the context placed blocks you'll need to use the block_get_blocks_by_region method of the context_reaction_block block class. You'll want something similar to

if ($plugin = context_get_plugin('reaction', 'block')) {
$plugin->block_get_blocks_by_region('region');
}

Though more generally, $plugin->execute($page_render_array) is called and the regions in the render array are populated by the block reaction. The block_get_blocks_by_region isn't declared as a private method but I would recommend exercising a little caution when using it should it change in the future. I don't think a change is very likely but wanted to mention it is a possibility.

tragic.rich’s picture

Thank you for the quick update! I will try out the code you provided.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

kumkum29’s picture

Issue summary: View changes

Hello,

I have the same problem on my site. The above code is it always functionnal ?
Here is my code to implement a custom region in a node.tpl:

<?php
$test_region = block_get_blocks_by_region('test');
print render($test_region);
?>

How can I modify this code for using context?

Thanks for your help.

kumkum29’s picture

Hello,

It's ok with the context_reaction_block class mentionned in #1 and with this post:
http://kahthong.com/2012/08/embed-drupal-block-region-node-page