I need to essentially trigger a context when a certain filter value is selected. Basically, in a view, when a filter is selected, based on the value selected I need to display a certain block.

Does anything like this exist? Or am I going to have to build my own extension to Context?

4 Answers 4


With Drupal there are so many way to do things - here is one way to achieve what you need:

  1. Go to admin/blocks and add your block to the region you want it to show up in, then set it to display on only the page for that view
  2. In your theme css hide that block (display:none)
  3. Add some javascript to display the block and bind it to the onchange event for the value you want, either add the js in your module or your theme.

I have not gone into specifics as each step can have variations on how you would like to implement them, but the above is one potential solution to the problem

Using context could work if you submit the view filter to a different path and then set a context to show the block on that path, but if you wnat to do it via an onChange its easier using Js & Css.

Modules that may also help:


There is a patch for the context module to achieve exactly what your are looking for. I've just installed it and tested it out and it works perfectly.

There is a thread on drupal.org about it here: http://drupal.org/node/904416

Scroll down to post 28 and download the patch.

To run the patch put it in the context module folder, and then run this command:

patch -p1 < 904416.28-context-query-string.patch

This is assuming you are using a linux terminal. If you want to do this in Windows or Mac then see this post: http://drupal.org/patch/apply

Once you have applied the patch then run update.php (just go to www.your_domain.com/update.php) and then flush the cache (always a good idea).

Now when you edit your context there is a new condition called Query String.

When I tested it out I had a field called category and I wanted my block to appear when it had the value of Javascript so I put "field_category_value=Javascript" as the value of the query string on the edit context page.

One thing to note here is that the block will only appear after the user has clicked Apply on the filter. If you want it to appear and disappear as soon as the value of the select box is changed then you will need to use Andre's solution.

  • I think it's easier to apply with git apply 904416.28-context-query-string.patch, but YMMV Apr 13, 2013 at 10:11

I found this module http://drupal.org/project/block_query and it does exactly what I need it to.

It lets you display a block based on query parameters.



This module introduces a context condition depending on query strings. Views exposed filters also work with query strings. So you can determine context conditions with the filter parameters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.