Taxonomy: A way to organize content

Taxonomy is the practice and science of classification.

Taxonomy is a method of organizing content on a site. For example classifying music by genere could generate this list: classical, jazz, rock. A single area such as "classical" might be further classified as concertos, sonatas, symphonies, and so on.

The Taxonomy module helps classify content on Drupal websites.

In Drupal 5 the naming of the Taxonomy module is inconsistent across the administrative interface. On the Administer >> Build >> Modules page, for example, the module is called Taxonomy. However vocabularies are administered through the Administer >> Content management >> Categories page.

The Taxonomy module allows vocabularies to be setup as either user defined tags (also known as folk taxonomy) or administrator defined terms.

When users view a post to which a term has been assigned, along with the post, many themes will generally display the node's term(s). Each term appears as a link. Clicking that link brings users to a page showing the other posts with the same term.

You can enable the Taxonomy module on the modules page (administer >> site building >> modules).

The Taxonomy module organizes taxonomies into vocabularies which consist of one or more terms. Vocabularies group terms that describe an aspect of the node.

These principles apply to defining a vocabulary with the Taxonomy module:

  • Each vocabulary consists of a set of terms.
  • A site can have an unlimited number of vocabularies each containing an unlimited number of terms.
  • Within a vocabulary terms can be ordered into hierarchies depending on the settings for the specific vocabulary.
  • Vocabularies may be designated as Free tagging in which users creating new content don't have to classify it with terms from a "controlled vocabulary," previously defined. Instead users can freely define terms, or "tags."
  • Vocabularies can be set to allow terms to define related terms. This functions similar to "see also" in a dictionary.
  • Vocabularies define whether users may attach only a single term to a node or whether users may attach multiple terms to a node.

Simple implementations might create a set of terms without hierarchies (like Slashdot's "sections"). More complex implementations you might use hierachies of terms.

By using multiple vocabularies it is possible to classify an individual node in multiple ways. For example a node representing a musical work might have a genre vocabulary and a time-period vocabulary including terms such as: seventeenth century, eighteenth century (perhaps with subterms like "early eighteenth century" and "late eighteenth century"). A single node might be identified using the genre vocabulary term "sonata," and times-period vocabulary term "eighhteenth century" and subterm "early eighteenth century." Adding a vocabulary for "composers," might lead to the the following combination of terms: as an "early-eighteenth-century" "sonata" by "Bach"--and locate it by any of these three terms.

Working with vocabularies

Vocabularies are managed on the taxonomies page (Administer >> Content management >> Taxonomy). You'll see a list of the vocabularies you've created, and you can edit each one.
You can add new vocabularies, using the add vocabulary tab at the top of the page. Or you can edit an existing vocabulary by clicking the edit vocabulary link next to its name (in the "Operations" column).

  • You choose a name for your vocabulary.
  • You can give each one a description, which modules may use in different ways. (For example, when users hover over a link that displays this vocabulary, they may see your description.)
  • You can tie your vocabulary to particular "content types"--"story," "book page," or whatever. Then when users create content of a particular type, they'll see a list of your vocabulary terms that go with it. Users can then categorize their post by choosing from the list. (You can also give your vocabulary a help text to help your users choose.)
  • Vocabularies can be set to allow hierachies of terms. There are three settings: disabled keeps all the terms on the same level; single allows terms to be nested but each sub-term is associated on only one parent; multiple allows a term to be associated to multiple parents. With either single or multiple a vocabulary can have as many levels as desired.
  • You can allow "related terms."
  • If you allow "free tagging," when your users create content they can make up their own terms as they go along, instead of having to choose from a list.
  • By choosing "multiple select," you can allow your users to put a post into more than one category at once by tagging it with more than one vocabulary term.
  • Also, if you like, you can require that when your users create content of a certain "content type" they assign at least one of this vocabulary's terms.
  • You can decide the order in which your vocabulary will appear in lists by assigning to it a "weight."
  • Finally, if you like you can delete the vocabulary altogether, thereby also deleting all its terms.

Working with terms

To view or manage the terms of each vocabulary, click on its list terms link. On the list terms page you can edit each term by clicking the edit link. Now, on the edit term page you have several kinds of choices.

  • If you've allowed this vocabulary to have a hierarchy, you can put the term in its place in the hierarchy by choosing the term's "parent."
  • You can select from this vocabulary one or more terms with which you'd like your term to be related. (You can select multiple terms by using the standard conventions of your operating system, like shift-click and control-click.)
  • You assign your term a name. (You have to do it. There's no such thing as a "nameless term.")
  • You can list synonyms for your term. (In taxonomy lingo, you're creating for your vocabulary a "thesaurus.")
  • You can decide the order in which your term will appear in lists by assigning it a "weight."
  • Or, finally, if you like you can delete a term altogether.

To add new terms to your vocabulary, click its add terms link. (The list terms page also has an add terms link that does the same thing.) When you add new terms you have the same options as when you edit them.

Using categories in menus

The menus on your site can call for items that match specific taxonomy terms--that is, terms you've named your categories. Here's how.

  • When you create a new term, Drupal assigns it a number. And you can call up all the items categorized under that term by calling for its number.
  • To see your term's number, go to the categories page, choose list terms for the category to which your term belongs, and now hover over your term's name in the list. You'll see the number.
  • Now, on the menus page (administer >> site building >> menus) you can create a menu item for your term. Select add item, and when you fill in the path field you add your term like this:

    taxonomy/term/1

    If the term "sonatas" is term 1, this would call for all the nodes of that category.

    If the term "Bach" is term 2, this could call for only those sonatas written by Bach:

    taxonomy/term/1,2

    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

  • If you are using a hierarchical taxonomy, and want all notes 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.

Several contributed modules make powerful use of the categories (taxonomy) module, exploiting and extending what it can do.

You can

  • enable the Taxonomy module at administer >> site building >> modules.
  • administer taxonomies at administer >> content management >> Taxonomy.
  • decide who else can administer the Taxonomy module at administer >> user management >> access control.
  • add a vocabulary at Administer >> Content management >> Taxonomy >> add vocabulary.

Creating menus from taxonomies

iantresman - May 15, 2008 - 22:25

See the Taxonomy Menu module to "Transform any of your taxonomy vocabularies into menus easily".

Taxonomy tags doesn't work with more than 3 tags

jayjaytheluffy - September 2, 2008 - 02:11

I've been experiencing a bug in my taxonomy module implementation. I added a new vocabulary and named it "tags" and applied it to a custom content type named "item". Everytime an item is created, the user has the choice to place "tags" for his new item by free-tagging. The problem is if there are more than 3 tags supplied as separated by comma, the node or new item is unable to be submitted. In Firefox, the submit button becomes inactive, though can be clicked but returns nothing (nothing happens that you have to refresh the page to have a new blank form). In IE and Opera, the submit button can be clicked but instead of saving the node, it just displays a new blank form.
Please I really need help on these. Our client have been reporting this bug but I'm afraid to go through the core module (taxonomy) that might mess up other things in our site.
I also posted this issue here as a sign of urgency: http://drupal.org/node/302512
Thanks

 
 

Drupal is a registered trademark of Dries Buytaert.