Spotlight Taxonomy

We have now played around with almost all of Drupal's basic site-building tools. There's just one more concept to cover in order for us to complete the functionality of Mom and Pop, Inc.: Taxonomy.

If you're new to Drupal, you've probably wondered what "Taxonomy" is—the word pops up all over the place, and it can sound a bit mysterious. Have no fear! It's just a technical term for a way of organizing and classifying things. If you've sorted your family photo album, filed your email in folders, or argued with a friend about whether a band is punk or ska, you've already worked with taxonomies!

Creating a taxonomy for your site starts when you identify what kinds of content you'll have, and how it can be described. Photographs, for example, might be classified by the subject matter, the location in which they were taken, or even the predominant color in the picture. In Drupal, these categories are called vocabularies. Each vocabulary contains specific terms (like Mountains or Automobiles or Pets) that can be used to describe content. Whenever you post a photograph, a music review, or a blog entry, you can select the terms that match it.

Drupal supports three kinds of vocabularies: simple lists of terms, organized hierarchies of terms, and "free tagging" vocabularies that allow you to define new terms as you post new content. Each is useful in different situations. Figure 2-37 shows an example of how each type of vocabulary might be used on a product content type.

Create

Titfe:

The Ami

Product zing Drupal!

:abularies

Product type:

Create

Titfe:

The Ami

Vo zing Drupal!

:abularies

Product type:

- None -

Apparel

-Hats

--Baseba 1 caps

--Toques

-Shirts

-Hoodies

--T-Shirts

Books

|drupai, furiny

A comni i-separated

Free tagging t of terms describing this content. Exampfe: Funny, bungee jumping, "Company, Inc."

Simple list

Figure 2-37. Examples of taxonomy types

For the librarians in the house, Drupal's taxonomy system also supports more advanced features of taxonomies such as synonyms, related terms, and multiple parent hierarchies. Whew!

After submitting a piece of content, any terms it has attached will appear as links on the node page, as displayed in Figure 2-38. Each of these links displays a page listing all content to which that term has been applied, along with an RSS feed that visitors can subscribe to in order to receive notifications whenever new content with that term attached is posted.

The taxonomy system is incredibly powerful, and is one of Drupal's greatest assets as a content management system. In addition to the features provided out of the box, several contributed modules also make use of taxonomy in interesting ways, such as Taxonomy Menu module (http://drupal.org/project/taxonomy_menu), which turns a vocabulary into a Drupal menu that can be placed in Primary or Secondary links.

The Amazing Drupal! /■iff I Edit

Add new comment Apparel dnjpal funny Polka-dot Elrsrts T-Shirts

Figure 2-38. An example of taxonomy assigned to a node

* - Each term has a unique ID that maps to its own dedicated URL in the system, such as http://example.com/taxonomy/term/3. These term list* v • i?' ings can also be combined; for example if "political" were term 3, and "humor" were term 4, the URL http://example.com/taxonomy/term/34 would display all content that was both political and humorous, and http://example.com/taxonomy/term/3+4 would display content that was either political or humorous. A book that was tagged only "humor, romance" would not show up in the first listing but would in the second.

0 0

Post a comment