Override taxonomy pages with Views 2

Last modified: October 1, 2009 - 21:42

Note: I have requested that this be added to Advanced Help within Views -- see http://drupal.org/node/495658

Views 2 provides an excellent way to override the taxonomy pages of any term. The view it's included by default but it's disabled. This page covers three minor aspects that some users could use to control the aspect of their taxonomy pages, it won't cover how to theme the view because this topic it's covered in some other pages of this book.

Background

The Taxonomy module provides a way to organize content through the site. It also presents a page with nodes that belong to some term. The style can't be changed easily and taxonomy only displays node teasers.

Force All

When using vocabularies with multiple term levels, a top level won't include the nodes that belongs to the levels inside. Let's clarify this with an example, let's assume the site have this vocabulary:

Vocab
- Term 1
   -- Term 2
   -- Term 3
- Term 4
   -- Term 5
   -- Term 6

If you go to taxonomy/term/1, then you see all nodes in Term 1 listed, but not nodes in Term 2 and Term 3. If you want to see all nodes in Term 1, Term 2 and Term 3 in a single page, you have to go to

taxonomy/term/1/all

With Drupal 5.x a user could 'Force' taxonomy to show 'all' terms inside another term with the Taxonomy Force All module. Unfortunately the module won't be upgraded to Drupal 6.x. Fortunately this can be done with Views 2.

Step 1. Enabling taxonomy_term

The first step we need to do is to enable the "taxonomy term" view that views provides for us. After we've done that we need to edit it.

Step 2. Changing minor aspects

On the Display: Page, we can change the Style to any of the styles that views provides for us, it could be a table or a list. If we do this it's necessary to add some fields to the view.

The most important thing we're going to change it's the argument Taxonomy: Term ID: (with depth). At the bottom of the screen, you'll have 2 options, the first one to change it's the depth, if we want to do what the Taxonomy Force All modules does, you'll have to set it up for at least 1.

The next thing you have to do it's check the Set the breadcrumb for the term parents option. This will allow your view to show the breadcrumb with all the term levels in your taxonomy.

Save the changes and try. Next you could do whatever you want, like adding fields, theming, exposing filters, sorting or adding feeds.

Theme every vocabulary/term independently

Thanks to TVI: Taxonomy Views Integrator now it's possible to theme every vocabulary or term with it's own view. All you have to do is clone the view in Step 1 and name it with one of the following options:

  • taxonomy_vid_tid
  • taxonomy_vid

You can read more about this module at the module page.

 
 

Drupal is a registered trademark of Dries Buytaert.