- Learning Drupal 8
- Nick Abbott Richard Jones
- 354字
- 2025-02-23 11:14:04
Taxonomy
One of the most powerful features of Drupal is the taxonomy system.
The word taxonomy comes from the ancient Greek word meaning 'the practice and science of the classification of things.
Consider a real-world example where Drupal might be used to manage, search, and display your music collection. It would be very useful to be able to categorize tracks within, for example, genre, because that way you could easily filter the entire collection down to say "soul" or "disco". Moreover, if you categorize the music tempo to say "slow", "medium", and "upbeat", then preparing a playlist of slow soul tracks would be simple just as you probably routinely do when using a dedicated organizer such as iTunes.
Thus, Drupal's taxonomy system is simply a means of enabling you to classify your content in many different ways.
The core taxonomy system allows you to define one or more vocabularies, each of which is a list of terms. For example, you may want to define an Article category vocabulary and associate it with your Article content type. The Article category vocabulary could contain terms such as "blog" and "news", thus enabling you to classify your Articles. The articles classified as blog appear on the blog page, and those categorized as news appearing on the news page.
A more abstract example might be to use taxonomy to categorize things by color. The vocabulary might be entitled Color
and then you would have the actual colors as the terms.
You could then use the Color
taxonomy to classify products such as t-shirts, socks, footballs, and so on, on a commerce site.
Fixed terms versus or tags
Taxonomies can be structured to have a fixed set of terms as discussed earlier, or they can be tag based in that the terms are defined as required when the content is being created just as you do when you are tagging content on say Facebook.
The Standard installation already has a single tag-based vocabulary called Tags associated with the Article content type.
Note
Careful planning of your taxonomy is essential to the ease of use and management of your website.