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.
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.
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.
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!
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.