Organizing content with taxonomy
Taxonomy is the practice and science of classification according to natural relationships. In Drupal, this is one method administrators use to organize content in a web site. Taxonomy is created from 'Vocabularies' that contain related 'Terms'.
A Taxonomy Vocabulary
classifying music by genre with terms and sub-terms.
- Vocabulary = Music
- term = classical
- sub-term = concertos
- sub-term = sonatas
- sub-term = symphonies
- term = jazz
- sub-term = swing
- sub-term = fusion
- term = rock
- sub-term = soft rock
- sub-term = hard rock
The Taxonomy module helps classify content on Drupal websites.
In Drupal 6 the naming of the Taxonomy module has been made more consistent across the administrative interface. Settings for taxonomy.module can be found at Administer >> Content Management >> Taxonomy
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 a vocabulary to be set up with 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 the link displays 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. In Drupal 6, all vocabularies are hierarchical (in other words, you can simply arrange items in a hierarchy). In Drupal 5 there is a setting for enabling hierarchical vocabularies.
- 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 might use hierarchies 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"). The node might also be identified using the genre vocabulary term "sonata". Adding a vocabulary for "composers," might lead to the the following combination of terms: as an "early-eighteenth-century" "sonata" by "Bach"--and it could be located 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). Note that when creating a new content type, existing vocabularies do not have the new content type selected; you need to edit them to add the type.
- Vocabularies can have hierachies of terms. In Drupal 6, you simply arrange items to create a hierarchy. In Drupal 5, 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 a "weight" to it.
- Finally, you can delete the vocabulary altogether, thereby also deleting all its terms (but not the nodes to which they were assigned).
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.
- You can put the term in its place in the hierarchy by choosing the term's "parent." (in Drupal 5 requires enabling a hierarchy for the vocabulary)
- 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 must 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. (this creates what is known as a "thesaurus.")
- You can decide the order in which your term will appear in lists by assigning it a "weight."
- 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/1If 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,2Or 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 nodes tagged with child terms to show up also, you can create an URL link like
taxonomy/term/2/2where the second parameter is the depth that the tree will be recursed into, ortaxonomy/term/2/allfor 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.
