Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Apress.Pro.Drupal.7.Development.3rd.Edition.Dec.2010.pdf
Скачиваний:
54
Добавлен:
14.03.2016
Размер:
12.64 Mб
Скачать

CHAPTER 15 WORKING WITH TAXONOMY

Figure 15-2. Configuration options for the new taxonomy field

After saving the field, the content creation form will now include a new field where the author can select from the list of terms associated with the vocabulary.

Kinds of Taxonomy

There are several kinds of taxonomy. The simplest is a list of terms, and the most complex has multiple hierarchical relationships. Additionally, terms may be synonyms of or related to other terms. Let’s start with the simplest first.

345

CHAPTER 15 WORKING WITH TAXONOMY

Flat

A vocabulary that consists of only a list of terms is straightforward. Table 15-1 shows how you can classify some programming languages in a simple, flat vocabulary that we’ll call Programming Languages.

Table 15-1. Simple Terms in a Vocabulary

Term ID

Term Name

 

 

1C

2 C++

3Cobol

Hierarchical

Now, let’s introduce the concept of hierarchy, where each term may have a relationship to another term; see Table 15-2.

Table 15-2. Hierarchical Terms in a Vocabulary (Child Terms Are Indented Below Their Parent)

Term ID

Term Name

 

 

1Object-Oriented

2

C++

3

Smalltalk

4Procedural

5

C

6

Cobol

 

 

Figure 15-3 shows the hierarchical relationships explicitly. In this example, Procedural is a parent and Cobol is a child. Notice that each term has its own ID, no matter whether it’s a parent or a child.

346

CHAPTER 15 WORKING WITH TAXONOMY

Figure 15-3. A hierarchical vocabulary has parent-child relationships between terms.

You can arrange terms into hierarchies when the term is created by selecting a parent term from the Parent field in the “Advanced options” section of the “Add term” form or by using drag and drop to position terms. After more than one term has been added, the drag-and-drop interface becomes available at Administer -> Content management -> Taxonomy by clicking the “list terms” link for the vocabulary you are working with. The drag-and-drop interface is shown in Figure 15-4.

Figure 15-4. Terms can be arranged into a hierarchy using the drag-and-drop interface.

Multiple Hierarchical

A vocabulary may have multiple hierarchies instead of a single hierarchy. This simply means that a term may have more than one parent. For example, suppose you add PHP to your vocabulary of programming

347

CHAPTER 15 WORKING WITH TAXONOMY

languages. PHP can be written procedurally, but in recent versions, object-oriented capabilities have been introduced. Should you classify it under Object-Oriented or Procedural? With multiple hierarchical relationships, you can do both, as shown in Figure 15-5.

Figure 15-5. In a multiple hierarchical vocabulary, terms can have more than one parent.

It’s worthwhile to spend a significant amount of time thinking through use cases for taxonomy when in the planning stage of a web site to determine what kind of vocabulary you need.

Because a multiple hierarchy vocabulary cannot easily be shown in a user interface, Drupal warns you that the drag-and-drop interface (shown in Figure 15-4) will be disabled if you select multiple parents for a term. The warning is shown in Figure 15-6.

Figure 15-6. Selecting multiple parents for a term will disable the drag-and-drop interface.

348

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]