Closed (works as designed)
Project:
Context
Version:
7.x-3.0-beta2
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
11 Oct 2011 at 15:04 UTC
Updated:
27 Aug 2015 at 17:05 UTC
Jump to comment: Most recent
Comments
Comment #1
Jason Dean commentedI'm finding exactly the same :(
Comment #2
dualcorpse commentedHi there,
There might be some better way to do it, but I found a workaround that works like a charm in templates files :
Instead of the classic :
With Context module, I use :
Note that if you're in a page--anything.tpl.php template, you can still use the $page variable :
Hope it'll help someone.
Comment #3
c7210 commentedit works!thanx man you saved my day!!
Comment #4
tekante commentedAs context bypasses the normal block placement mechanisms of core it is expected that the block_get_blocks_by_region function will not return blocks placed using context. Closing this as information about how to approach this with context has been provided.
Comment #5
peteainsworth commentedThanks for this, it really helped me out. For anyone coming across this thread, to avoid a
error, add the code to your template.php:
and then add this to your node.tpl.php:
Comment #6
jrogen commentedThe suggestion in #5 didn't quite work for me. I found the solution here: https://www.drupal.org/node/966768
Just add the line:
drupal_static_reset('context_reaction_block_list');below the line setting $vars and the blocks rendered correctly for me.
Comment #7
jimkeller commentedI was using this method of printing context regions in the node with success, until I had more than one context active. It seemed that the preprocess function was running multiple times, and the block content was empty on the final run (possibly because Drupal won't print the block content for the same block twice?)
I'm not entirely sure this was the best way to handle it, but it seemed to work; basically just caching the value one time and not letting block_get_blocks_by_region run over and over. However, I'm not sure how this will act with more complicated context set-ups:
Comment #8
rooby commentedDepending on the context configuration I was still getting incorrect blocks with the above examples.
The main issue I had was the context_disable_context module was being used to disable certain contexts and that wasn't being taken into account.
This seems to work but I need to do some more thorough testing to make sure it has no negative effects.
I used this code to load all core drupal blocks combined with all context blocks and then properly render the region with correct templates.
Note that I had to invoke the context hooks. That may not always be necessary but I'm not sure yet.
This will render the sidebar_first region:
You can then use drupal_render() to render that region variable.