Last updated by Anonymous on Sat, 2009-03-28 19:06
In Drupal, taxonomy.module implements hook_term to provide links among content which shares a given term. Site builders often use this feature to provide indexes and RSS feeds of their content.
Taxonomy.module's purpose is to support the creation of controlled vocabularies which we can use to classify our site's content. If taxonomy.module were a prescription drug, this would be its "on-label" or indicated use. Using taxonomy.module vocabularies and terms to store essential data about our content is what I call an "off-label" use. You're not really creating a controlled vocabulary, and the term-node relationship in these cases isn't always classificatory.
However, a clever web developer will use the tools that get the job done, and often taxonomy.module is the perfect tool for making this happen. Because this information is essential to your node's content, CCK fields are indicated for this use. However, CCK fields don't have built-in linking among nodes which share values for the same field. Also absent is any built-in RSS feed for a CCK field's value. This requires some theming and Views.
This example is for Drupal 6, CCK and Views 2.
I created a content type "parks" with a text field "district" with allowed values north, east, west, and south. Then I created a view also called "parks" which is a clone of Views 2 default "taxonomy_term" view. I deleted the arguments in the cloned view and replaced it with the CCK field "district." This view will display a simple teaser list of content where the values for this field are the same. Finally, I overrode the district field theme with a new template, which prints a link to the view instead of just the CCK field value.
It's important to remember that you must include the default template for CCK's content-field.tpl.php in your theme before you can override specific CCK fields. Drupal 6's theme layer will not look in your theme for any suggested template files unless the base suggestion already exists there.
The example is attached here as three files.
| Attachment | Size |
|---|---|
| park content type (for content copy module's import feature) | 3.42 KB |
| parks view | 4.98 KB |
| content-field-field_district.tpl.php | 1.64 KB |