This document discusses using taxonomy to categorize content in Drupal. It covers creating a taxonomy vocabulary and terms, then adding a term reference field to a content type so authors can categorize content. It also introduces the Taxonomy Manager module for a better user interface for managing taxonomy.
Drupal 7 Taxonomy Homework - Categorize Content with Hierarchical Terms
1. Introduction to Drupal 7
Session 2.3 - Homework
Taxonomy Categorization
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 1
2. Homework
• Read this through
• Create categorization for your news content
type
• The categorization should be in a taxonomy
reference field
• There should be a hierarchy categorization
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 2
3. Agenda
• What is Taxonomy
• Managing taxonomies
• Taxonomy categorizations to content types
• Taxonomy manager module
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 3
4. Taxonomy
• provides a mechanism for categorizing
content on your site
• In Drupal taxonomy is divided into two
elements: a vocabulary and term
• A vocabulary is simply a group of related
terms
• A term is a word or phrase that describes a
distinct aspect of a vocabulary
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 4
5. Taxonomies
• Flat structure – no hierarchy – Tags example
• Hierarchy – Categories with levels and sub-
levels
• No limitations on the number of vocabularies
• No limitations on the number of terms
• No limitations on the depth of categorization
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 5
7. Our news categories
• News about products
• News about services
• General news
• Team news
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 7
8. Adding taxonomy category to a
content type
• Decide which content type will be categorized
with a given taxonomy vocabulary;
• Include a reference field to the vocabulary
that we wish to link to the content;
• One field with a given taxonomy term
reference can be shared b/n content types;
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 8
9. In our case
• The news content type has several categories
• We need to create a taxonomy vocabulary for
the category
• We need to add several terms to the
taxonomy vocabulary
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 9
10. Adding terms reference field
• Administration > Structure > Content types
• Decide which content type will take the terms
categorization
• Click on the “manage fields” link;
• To add a new term reference field:
– Enter a value in the “Add new field”
– OR
– Choose a field from the already created fields list
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 10
11. Adding new field explained
• Add new field > This is the label of the field
• Category > has to be machine readable
– No white spaces, special signs, etc
• Term reference is the field type you need
• Type of term reference widget
– Select list > Drop down with option values
– Check boxes/ radio buttons > depends on # of values
– Autocomplete term widget > As the default Tags field
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 11
12. Taxonomy term reference field
• We want the Office Assistant to be able to
select multiple pre-defined values
⇒ We need the “Check boxes/ radio buttons“
⇒ “Number of values” option should be
“Unlimited” to have checkboxes instead of radio
buttons
⇒ The autocomplete type of widget is also possible
in this case, but it’s better to enable the OA to
choose a category of predefined visible options list
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 12
13. Selecting a term on content edit
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 13
14. Seeing the taxonomy term ouput
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 14
15. Working with hierarchies
• Drupal provides a simple mechanism for
creating and managing hierarchical structures
of taxonomy terms – use the handles ☺
Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 15