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.

Comments

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

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

Add new comment