wholesale

Submitted by seointern on Sat, 12/29/2007 - 14:49.

Taxonomy: A way to organize your content

The Taxonomy module lets you classify content into categories and subcategories, thus organizing the content on your site. For example, you could classify music by genre: classical, jazz, rock. And you might further classify "classical" into concertos, sonatas, symphonies, and so on. When your users create new content, you can let them classify it (or even require them to do so) right when they create it.

When users view a post to which a category has been assigned, along with the post your theme will generally show the name of the category (or categories) to which the post belongs. Each category's name appears as a link. And clicking on that link will bring users to a page showing the other posts of the same category.

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

The categories module is also sometimes called the taxonomy module. Taxonomy means "division into ordered groups or categories." Taxonomy also refers to the science or principles of classification. In the language of taxonomy, groups of categories are called "vocabularies," and the categories themselves are called "terms."

With the categories module you can define groups ("vocabularies") of categories ("terms") by which to classify content.

  • Each vocabulary consists of a set of terms.
  • You can have as many vocabularies as you want and for each create as many terms as you want.
  • You can order your terms into hierarchies.
  • You can also have "free vocabularies," in which users creating new content don’t have to classify it with terms from a "controlled vocabulary," one you’ve defined. Instead they can freely define their own terms, or "tags." (This is sometimes called "free tagging.")
  • When you create a term, you can also tie it to related terms. (Think of "See also" in a dictionary.)

You can allow users to classify each piece of content they create--each story, blog item, or whatever--using one term or many.

For simple implementations, you might create a set of categories without subcategories (like Slashdot’s "sections"). For more complex implementations, you might use subcategories too, thus organizing things into a hierarchy.

To further organize your site, you can have groups of categories intersect. For example, intersecting your musical genres you might have a set of categories indicating times: seventeenth century, eighteenth century (perhaps with subcategories like "early eighteenth century" and "late eighteenth century"). So, using our "genre" vocabulary we might call an item by the term "sonata," and using our "times" vocabulary we might call it by the term "early eighteenth century." If we add a vocabulary for "composers," we might categorize the item three ways--as an "early-eighteenth-century" "sonata" by "Bach"--and locate it by any of these three terms.

Working with vocabularies

On the categories page (administer >> content management >> categories) you can create, view and manage your categories. 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.)
  • You can make choices about the hierarchies for your vocabularies. If you want all the terms to be on only one level, choose "disabled." To allow your terms to have one (but only one) level of terms below them, choose "single." And if you want to allow still further levels, choose "multiple."
  • 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 category like this:

    taxonomy/term/1

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

    If your category "Bach" is term 2, you could call for only those sonatas written by Bach:

    taxonomy/term/1,2

    Or if Brahms is term 3 and you want to call for everything that has to do with either Bach or Brahms, you’d do it this way:

    taxonomy/term/2+3

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

You can

  • enable the categories module at administer >> site building >> modules.
  • administer categories at administer >> content management >> categories.
  • decide who else can administer categories at administer >> user management >> access control.
  • add a vocabulary at administer >> content management >> categories >> add vocabulary.
 
Syndicate content