You are here

Taxonomy

Taxonomy is required for a number of things you will probably use in Drupal. Try a basic Drupal installation and then experiment with taxonomy.

I do not recommend Drupal's taxonomy system as a starting point for learning Drupal. The taxonomy approach is probably the biggest sticking point in setting up a Drupal based site. Install a default Drupal installation and learn about templates, themes, modules, functions, and hooks before attacking taxonomy.

The Simplenews module requires taxonomy and is a good starting place to learn how taxonomy works. You set up a list of newletters as a list of terms in a vocabulary. You simply switch on taxonomy, create a vocabulary named newsletters, add a term for each newsletter containing the name of each newsletter, then Simplenews displays the selection list in the page for creating newsletter issues.

Forum and other modules use taxonomy but often in complex ways that are really hard to understand. Start simple and build up.

You will have to plug in a few modules to make taxonomy useful. Taxonomy Menu is a taxonomy extension module I recommended for earlier version of Drupal but Taxonomy Menu was slow to arrive in Drupal 6 so I dropped it and stopped using Taxonomy. Taxonomy Menu now has a completely rewritten version for Drupal 6 but the documentation is still lacking in examples of use.

In drupal 4.6.0 I had to write extra code and an extra module to cover everything I need from taxonomy. Drupal 6 has better code and has examples of some uses for Taxonomy. Perhaps a future Drupal will have all the options already build, full documentation, and provide a nice roadmap for installing the parts you need.

I started a site with taxonomy and then ripped taxonomy out because it was too complex for what I wanted. Later on I found out there were useful taxonomy modules listed under Drupal 4.5.0 but not under 4.6.0. A couple of weeks later the extra modules were upgraded to Drupal 4.6.0 and I tried taxonomy again. It was still too hard.

My third attempt at taxonomy was because I wanted to use a Drupal module for handling images and that module used taxonomy. By my third attempt I had found out enough about Drupal hooks and functions to make the minor changes need to get Drupal's taxonomy working for my sites.

Tables

The taxonomy module produces and maintains tables term_data, term_ hierarchy, term_node, term_relation, term_synonym, vocabulary, and vocabulary_node_types.

Install

Taxonomy is supplied as part of Drupal. You do not have to download anything extra.

  1. Go to administer > modules and switch on taxonomy.
  2. Go to administer > access control. Assign taxonomy administration to content creators.
  3. Go to administer > categories and add your first vocabulary. When you install taxonomy menu, the vocabulary name will appear as the high level menu entry.

Vocabulary Settings

There are a lot of settings at the vocabulary level. The weight setting is used to position the menu entry for the vocabulary entry when you are using taxonomy menu.

You can set the hierarchy option to single or multiple. I used the single option for this site when I used Taxonomy for menus.

The related terms option looks useful and I turned the option on. You get a Related terms entry box when you edit a page. I found a note that says the related terms are used by the search module.

Add Terms

You can now add terms. Add some so that you can experiment with terms when you create a page.

Modifications

Taxonomy Menu uses the Taxonomy module to help produce the descendant list for a page. The taxonomy module defaults to sorting the list by the node sticky indicator and then the date of creation in a descending order. I find the best sequence is ascending alphabetical order to match the menus and the indexes in book pages. I modified an SQL statement in the taxonomy module to return the list in the right order.

Taxonomy taxonomy_select_nodes() sorts entries by n.sticky desc, n.created desc. Taxonomy menu displays menu entries in alphabetical order. I modified Taxonomy to sort the same using n.sticky desc, n.title. Perhaps the option could be a configuration setting. I suggested the modification for an administration setting. One of the Drupal developers made an arbitrary decision to defer the work and to require the use of an optional module that many sites reject because the code is too heavy.