Profile picture for user admin
Daniel Sipos
08 Apr 2013

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.

Profile picture for user admin

Daniel Sipos

CEO @ Web Omelette

Danny founded WEBOMELETTE in 2012 as a passion project, mostly writing about Drupal problems he faced day to day, as well as about new technologies and things that he thought other developers would find useful. Now he now manages a team of developers and designers, delivering quality products that make businesses successful.

Contact us

Comments

thedavidmeister 08 Apr 2013 13:41

Context error http://drupal

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

Daniel Sipos 08 Apr 2013 15:36

Thanks a lot for the comments

Thanks a lot for the comments guys!

hazah 08 Apr 2013 21:22

Context Redirect

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

Jeremy Caldwell 09 Apr 2013 06:40

Context Breakpoint

Rather than using the Context Mobile Detect module and relying on user agents I chose to go with the Context Breakpoint module (http://drupal.org/project/context_breakpoint) 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.

Anonymous 10 Apr 2013 08:20

Context URL - http://drupal

Context URL - http://drupal.org/sandbox/gianfrasoft/1387780
Provides URL Context condition.

Derivicon - http://drupal.org/project/derivicon
Context reaction to apply Image styles to the Favicon
 
Contextual variables - http://drupal.org/project/context_variable
Context reaction for temporarily changing variables
 
Contextual modules - http://drupal.org/project/context_module
Context reaction for disable/enabling modules
Gianfrasoft 10 Jun 2015 13:45

In reply to by Anonymous (not verified)

Context URL

Context URL is no more in sendbox:

https://www.drupal.org/project/contexturl

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

azul 15 Aug 2013 14:58

wow these are great modules,

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

How to use emoji on iphone 5 13 Feb 2014 19:21

Great post, thank you much

Great post, thank you much for sharing this :)

Add new comment