In the previous blog post, we have introduced some basic concepts of Taxonomy in Drupal. Now we will extend this topic to Taxonomy in Menus and Views.

Using terms in menus

Sometimes you want your navigation menu to display terms that you have created. Like this Symphony website, I created a term called "Theme", because this is a Drupal theme website. So I need to put this term to my main menu.

The menus on your site can call for items that match specific taxonomy terms, ie, terms you've named your categories. When you create a new term, Drupal assigns it a number. To see your term's number, hover over your term's name in the list terms. You'll see the number.

To create a taxonomy menu item

  1. On the menus page, select add item, and fill taxonomy/term/1 in the path field.
  2. If the term "sonatas" is term 1, this would call for all the nodes of that category.
  3. If the term "Bach" is term 2, this could call for only those sonatas written by Bach: taxonomy/term/1,2
  4. Or if Brahms is term 3 and this will call for everything that has to do with either Bach or Brahms: taxonomy/term/2+3
  5. If you are using a hierarchical taxonomy, and want all nodes tagged with child terms to show up also, you can create an URL link like taxonomy/term/2/2 where the second parameter is the depth that the tree will be recursed into, or taxonomy/term/2/all for all child terms. 

Display contents with the same layout for all terms of a Vocabulary by view module 

By default, Term link to category pages (taxonomy/term/[tid]). I found that category pages are more useful than custom views because you can control fields. You can replace the default category pages with a customized view by following steps: 

  1. Go to view list page at admin/build/views and create a new view.
  2. At Fields settings: add Node: Title, Node: body.
  3. At Filtter setting: add Node: type Story, Node publish yes
  4. Add Page Display.
    • Add path: taxonomy/term/%
    • At Arguments setting, add Taxonomy: Term ID (or Taxonomy: Term ID with depth) and config it like this image:
drupal_taxonomy_view

If you want to create two category pages for Terms of two Vocabulary which have diffirent layout, you can add 'taxonomy1/term/%' for path of the first views and 'taxonomy2/term/%' for path of the second views. And theme use 'taxonomy redirect' module to redirect them to the new path.

Part 1: Taxonomy Drupal Tutorial - basic concepts

Comments

I am trying to embed a call

I am trying to embed a call to a taxonomy term in the template for the custom pagers module, so that, when a node of a photo to a photo gallery is displayed from a gallery that is created by a view using taxonomy arguments, I can have an easy way for the viewer to go back to the gallery thumbnail display.

Do you know if there is a way to use these types of arguments within the template, so that my viewer can go back?

This was just what I needed

Thank you, this was what I was looking for. Tried the Taxonomy Menu module, but it messed up my menu system. This is a simple and secure way of adding menus to your taxonomy stuff.

Thanks!
Arne

Subscribe to our mailing list

* indicates required