19 - March - 2010

Views 2 - Intelligent Taxonomy Filtering

Post by Mike C
Ixis Service

A recent request from a client was to improve the Views 2 exposed taxonomy filter so that it intelligently hides taxonomy terms which aren't related to any of the content returned by the View query. As anybody who has spent time poking about in Views vast configuration panel will know, this isn't possible through the existing Taxonomy handler.

Stackoverflow.com had a few posts from users requesting the same functionality, and replies from others saying it wasn't possible with Views 2. Well the good news is: it is possible, right now, without hacking Views.

For our specific project then taxonomy list was to only list the terms which related to the nodes returned by the initial (un-filtered) View display query. Once taxonomy terms are selected and the filter applied the taxonomy term list still needs to show a list of terms from the original query of nodes, not the currently filtered list. This prevents the taxonomy term filter from slowly shrinking down without providing a means to go back to other taxonomy terms.

The solution was to take the default taxonomy filter handler in Views core and modify it as a replacement handler.

To make the traditional multiple select list more user friendly (no CTRL click rubbish) we added a layer of jquery thanks to the Simple Multi Select plugin and some CSS in the sites theme to show tick box images next to the selected items.

The finished example can be seen at the top of the http://www.betterregulation.com/uk/news/last5days page.

The developed code is now available on drupal.org. Be sure to pay attention to the side effects of using this filter.

Mike C

Managing Director

12 years of Drupal development wrangling and a background in digital project architecture.


what are the side effects we should pay attention to ?


The side effects are listed under the 'Notes' subheading on the project page of the new module.


In reply to by Adrian

i hope intellingent taxonomy filtering works well one day because i think that righht now it doesn't

map quest

For our specific project then taxonomy list was to only list the terms which related to the nodes returned by the initial (un-filtered) View display query.

Wylewki Bielsko

I basically want to display a block of node content that will accept multiple terms from a contextual filter to display nodes that have the same term applied. E.G. Say node 1 has terms a,b node 2 has term a and node 3 has term b, if this view were to be displayed on node 1 you would see both node 2 and 3, however if you saw it on node 2 or 3 it would only should node 1.

Is this possible with this module?

Jess @ Acousti…

Add new comment

Share this article

Sign up to our newsletter!

Our thoughts

Let's work together

Get in touch and find out how we can empower your organisation.
Back to top