Need some help with your project? Contact me

5 cool modules that extend Context

Anyone who ever used the Context module already knows the power and value behind it. By default, you get a number of handy conditions you can set (a context) in order to allow various things to ‘happen’ on your site. For instance, you can change the positioning and visibility of your blocks depending on various conditions. Cool stuff.

So I wanted to show you here 5 cool modules that extend Context to make it even more powerful. Although there are plenty of others out there, I chose these 5 because I thought they are particularly interesting. So let’s check them out.

Context Rules

I’m sure you are already familiar with the Rules module. If you need some dynamic workflows on your site, Rules is for you. It basically lets you create triggers, conditions and reactions for all sorts of stuff you need to happen automatically on your site. Drupal Commerce for instance relies heavily on this module.

Anyway, Context Rules provides a bridge between the two. It provides a Rules event that reacts to a set Context, a condition to check if a certain Context is set and the possibility to set or unset a Context automatically with Rules. Pretty cool, so do check it out.

Context Date

This is a simple but useful module. Basically it answers the question: what if I want a particular Context to be active only in a given period of time? For instance, I want the Context to be active only from next Monday till Friday. Enter Context Date.

It offers a new condition that checks the current date before activating a particular Context. Just FYI, the Date module comes with a Context integration module that provides a Context condition that checks for the value of a Date field. So do check that out too if you are interested.

Context Mobile Detect

Because it’s all about responsive design now right? Context Mobile Detect offers a new condition that checks for the device the site is being viewed on. So you can make sure that a given Context gets activated only if the user is on a mobile, tablet or desktop device. Moreover, you get another condition that checks for the actual device type (such as iPhone or Samsung).

This all happens with the use of the .php Mobile Detect library, which means this happens server-side rather than using media queries for dynamic changes. But do check it out nonetheless.

Context Respect

I wrote a while ago about a neat little trick of using Context to place your blocks around on your site. I argued that using this module you can not only control visibility, but also position variations between pages. Using Context Respect, you can decide who takes priority when there is a conflict between the visibility settings of a Context and the block configuration itself.

If you install it, by default if there is a conflict, the Context loses. I think this is a good default. However, when you edit the block, you can override this behaviour and allow the Context to display the block even if the block’s configuration says the contrary. Very useful!

Context Redirect

This is another simple module that offers a Context reaction to redirect the user to an internal or external URL if the conditions have been of course met. Additionally, it provides an admin tool that allows you to stop the redirect from happening. All you need to do is declare a variable that you then pass to the URL that would be normally redirected and the reaction does not happen. Simple but handy, so do check it out.

And this is it for now. I don’t know if you knew about all these modules but I’m sure they can be very helpful. If you have any thoughts or ideas, let me know down below in the comments.


Don't forget about Context Add Assets, it's pretty cool too! :)

Context error is pretty promising too, but there's a few outstanding patches in the issue queue that need review/committing.

Thanks a lot for the comments guys!

This one has had some fairly significant problems. Ultimately it may not be the best redirection solution.

Rather than using the Context Mobile Detect module and relying on user agents I chose to go with the Context Breakpoint module ( and use breakpoints to adjust the rendering of my blocks and content. So no more "display: none" as you can set specific blocks to render based on the breakpoint. Very handy for responsive development and serving up a lighter page and assets to mobile devices.

Thanks a lot Jeremy for that good tip!

Context URL -
Provides URL Context condition.

Derivicon -
Context reaction to apply Image styles to the Favicon

Contextual variables -
Context reaction for temporarily changing variables

Contextual modules -
Context reaction for disable/enabling modules

Context URL is no more in sendbox:

Provides URL Context condition even if you are using different domains or subdomains!

wow these are great modules, context breakpoint help me alot making drupal theme responsive

Great post, thank you much for sharing this :)

Add new comment

You can post comments in Markdown and basic HTML tags.
For code blocks, wrap your code within '~~~'. For example:
$var = 'my variable';