Using different views for different vocabularies or terms

in drupal, taxonomy, views, tvi

You really aren't using Drupal right if you're not harnessing the power of taxonomy, and you haven't seen much of it until you understand views. The only limitation for me was that you have to streamline all terms to look alike, in order to fit in the same templating. Well, not anymore!

The idea behind the Taxonomy View Integrator (TVI) is simple yet powerful: You edit an existing vocabulary (or term!) and you can select a specific view and display that you will be used to render the specific terms ( either for the whole vocabulary or the specific term. If you need an example to better understand the power in your fingertips, imagine the following scenrario:

  • You have a content type "Paint"
  • You have a vocabulary "Colors" which has various colors defined as terms ( eg "Red" )
  • You have a vocabulary "Bucket" which has the various sizes defined as terms ( eg "Large" )

Old behavior: when you visit either term ( Red or Large ) you got the same style, and same fields, unless you did some CSS-fu based on the aliased path, or some template magic.

Well no more! Now you can simply create two displays and have a grid view with color related fields in the first case ( eg type of red paint, surfaces etc ) and container related in the second ( metallic or whatnot ). Then simply edit your vocabulary and select the newly created view, and enable TVI for it; you're now in business!

What's more, you can define a different view for a specific term -- eg if you wanted Red to have a different layout.

The example might not be the best, but I'm really excited about it since coding required for making client fantasies a working thing have gone down a notch!

For some reason it isn't that easy to find -- hope this will help someone out.