Understanding Vocabularies and Terms

Drupal divides the task of categorization into two general concepts: vocabularies and terms. A vocabulary represents a general concept and is collection of words or phrases that are all different ways of describing the same thing. A term is a word or phrase providing a concrete example of the vocabulary's general concept.

For example, if Animals were a vocabulary, dog, bird, fish, and cow would all be terms in it. If you were trying to categorize the news, you might use terms like International, State, and Local to describe the different types of news. In Drupal, that structure would be represented with a vocabulary News that has three terms:





Vocabularies can be assigned to different content types. This allows you to categorize every post of that type using the terms in the vocabulary. If you were to assign the News vocabulary to story types, every time you created a new story, you would have the choice of categorizing it as International, State, or Local. When the content is viewed, Drupal displays category links indicating how the content has been categorized and leading to pages that show other content in the same category.

These features alone make categories a great tool for organizing the content on your web site. They allow visitors to get to all of the posts that have been made within a certain category and give content creators an opportunity to classify the content they are creating.

The category system is capable of much more, however. The hierarchy of a vocabulary is not limited to a simple list of terms. For example, you could expand the International term of the News taxonomy to have subcategories as well:


International Politics Business Travel

Here, the International term has three subterms: Politics, Business, and Travel. In this case, those three terms have International as a parent. If each term can have only one parent,

Drupal calls it a single hierarchy. A multiple hierarchy exists when terms can have multiple parents, as illustrated in Figure 2-6.


This flexibility allows you to model very complex relationships within a vocabulary. To add to the possibilities, you can create many different vocabularies, and each content type can have more than one vocabulary assigned to it. This allows you to not only categorize your content, but to categorize it in different ways or realms. The hierarchy in Figure 2-7 could be replaced, for example, with two vocabularies: News Area and News Topic.

News area

News topic

• International

• Politics

• State

• Business

• Local

• Travel

Figure 2-7. Multiple vocabularies example

Using these two vocabularies, you could provide very detailed information about every story (or any other content) that you write. Your site could then easily be organized into sections like International News, Regional News, and Local News, each with the subsections Politics, Business, and Travel.

Drupal is also capable of listing the content in different categories or combinations of categories based on the information it receives in the URL. This means you can easily make custom sections that display local news about politics simply by entering the correct URL. Category listings—even complex listings built from two or more terms—have their own RSS feeds, so visitors to your site can easily subscribe to the various categories or channels with their feed reader, without requiring you to program anything. Finally, there are many Drupal modules that use the category system for a wide variety of tasks, such as creating the structure of forums or image galleries, making site navigation menus, providing access control to content, and changing the theme to style different sections of your site differently. As you can see, the category system adds whole new dimensions to what your site can achieve.

Was this article helpful?

0 0

Post a comment