
Content types and taxonomy: A detailed look
In the previous versions of Drupal, there was a very popular suite of modules called CCK (Content Construction Kit), the main purpose of which was to make it easier for administrators to create new customized content types, with more options and fields available to them. Much of the Content Construction Kit code has now been brought into the core Drupal 7 installation, negating the need to install the module. As a result of this, the core taxonomy module has been updated to make use of this feature, to make it easier to define how content can be categorized.
Tip
What is taxonomy?
Taxonomy is a powerful module which makes it easy for us to group and categorize our content. This could be by entering a keyword, a series of keywords, or selecting a category from a drop-down list. Categorized content can then be aggregated and displayed together through useful lists of content.
Let's have a look at customizing content types and how taxonomy links into it.
Creating a new content type
If we go to Structure | Content types | Add content type, we can start creating a new content type. At this stage we don't have a genuine need to create a new content type other than to look at the feature in more detail, so we will use test data.
The first half of the form asks us to enter a name and a description for the content type. Drupal automatically generates a "machine name" for this content type based on its name. This is a reference it uses, which must be formatted in a certain way:

The second half of the form provides us with options to set the name of the Title field, and also other customizable information, including:
- If the user creating content of this type must first be shown a preview before the content is saved
- Explanation or submission guidelines to explain how to create or edit content of this type
- If the content should be published, promoted, or sticky (although Administrators can override this when creating content of this type)
- If the author's name and publication date should be displayed with the content
- If comments are permitted, and various settings to go with that
- Which menus it will be possible for this content to automatically go in, and the default parent item for it
The following screenshot shows the submission form settings option and the other setting groups which can be configured:

Once we have completed the form, we should click the Save and add fields button.
Adding fields to the content type
Now, the content type is saved, and we are presented with the MANAGE FIELDS screen, from which we can edit the fields associated with the content type, and associate new fields with it. These fields are what the user will be asked to complete when creating an element of this content or instance. If we wanted to create a directory of physiotherapists who work with dinosaurs, we might add fields for address, contact number, website, and a list of breeds they work with (taxonomy). Then when the user creates a record of that content type, they are prompted to enter information for all of those fields we have created:

If we wanted to add an address field to the content, we would simply call the field address, put address in the name field, select Long text as the field, and select Text area (multiple rows) from the Widget drop down:

The types of field we can create are:
- Boolean
- Decimal
- File upload
- Float
- Image upload
- Integer
- List (of floats, integers, or text)
- Long text
- Long text and a summary
- Term reference
- Text
Linking taxonomy to the content type
If we now wish to link a taxonomy vocabulary to our content type, we need to select Term reference from the field drop-down list. With that selected, we have three options for Widget:
- Select list: A list of the options which can be selected
- Checkboxes / radio buttons: If only one can be selected, then radio will be used; if more than one, checkboxes will be used
- Autocomplete term widget: Allowing the user to type part of the work to associate with the content, and select the actual word from a list, or enter a new word they wish to associate with the content:

Once we have added our taxonomy field to the content type, we need to click the Save button at the bottom of the page.
Customizing how the taxonomy works with the content type
After clicking Save, the field will be created and saved so that it can be used with other content types in the future. We can now select the taxonomy vocabulary we wish to use, and then click on the Save field settings button to save the field:

Finally, we are taken to more detailed settings about the field, where we can indicate if the field is required, provide help text to the user, and even provide a default value, and select the maximum number of terms which the content can be associated with.
Test content in action!
If we now go to Content | Add content | Test content type, we can create a new element of this content type and see the options in action!
The first thing which is noticeable is that the Title field is showing up as Heading (as we named it in the settings):

Beneath the content field, we have our Address field, and our taxonomy field of Keywords:
