drupal cck vs taxonomy
Drupal provides two methods for adding structured data to a node.
The first is the out-of-the-box Taxonomy module. Taxonomy allows you to associate a vocabulary with a content type. When creating or editing the node, you are invited to choose a value for the vocabulary from its associated list of terms. In essence, you are associating a structured field with your node. The name of the field is the name of the vocabulary and the value is the selected term.
The second method is the CCK module. The terminology of CCK is less confusing. Using CCK you define fields and associate these with a content type. When creating or editing the node, you are invited to set values for the associated fields. There are a few obvious differences between Taxonomy and CCK
- CCK fields can be created with many different data types (text, integer, image). Taxonomy terms are always text.
- The terms in a vocabulary may be arranged into an inheritance hierarchy. There is no such concept with CCK fields.
- Taxonomy vocabularies are exposed in the out-of-the-box Drupal advanced search feature. Combined with a hierarchical vocabulary, theoretically this allows for very sophisticated searching across site content.
But, the core functionality is the same - they both allow you to add structured data to a node. So, how do you know which of these methods you should use? After much experimentation, here are some simple rules I've found useful.
- Use Taxonomy to classify your content.
- At first, this decision seemed obvious, because Taxonomy is built into advanced search. However, when I discovered that the advanced search feature does not correctly search your taxonomy hierarchy, I became dubious that there was any point to Taxonomy whatsoever. If you could not perform a hierarchical search, what on earth was the point?
- Enter the Views module. Even though the out-of-the-box Drupal advanced search feature is not actually fully integrated with Taxonomy, the Views module is. You can easily use the Views module to create a personalized version of advanced search. As long as you set the magic "Option" flag to be the depth with which you want to search your taxonomy, Views-based searches will correctly perform hierarchical searches.
- Use Taxonomy to manage permissions
- Out of the box, Drupal allows you to set different permissions for different content types. E.g. you can allow a particular role to edit only a particular subset of content types.
- This is nice, but can get a little clunky. Suppose you are a news site, and you want to define a content type called "News Article". Suppose you have defined a vocabulary called Region with terms south-west, north-west, mid-west, south-east and north-east and that you have a different reporter assigned to each region and you only want to allow the north-west report to edit north-west articles, etc.
- One option is to make a bunch of different Content Types, one for each region. The other option is to install the Taxonomy Access Permissions module. This allows you to set permissions using the Region vocabulary.
- Use CCK fields for everything else
- In the end, CCK is more flexible, so for most other structured data needs, it should be just the ticket!