Content types are the real driver to creating content for your website to satisfy your own particular requirements. In some cases an installed module will create content types for you to use such as the Blog and Book content types that come with Drupal core. E-Commerce modules use content types to configure the store and the number of content types will continue to grow as you specify the functionality on your Drupal website.
Content Type Settings
Every time you add some information for a content type a node is created in Drupal that has a URL which displays the content, for example http://drupalsite/node/98. You are able to give the node a different meaningful alias from the URL options at the bottom of the content creation page.
You can specify default options for a content type that applies to all newly created notes and allows you to specify whether the content is published immediately, is attached to a menu item, displayed on the front page and so on. Editing the content type allows default values to be set for the content type so that comments, for example, can be disabled for a particular content type. Additional modules may add functionality to each node and build on this concept so the functionality can be applied across all content types and nodes.
Recently a new framework known as the Entity API has come into use that is more efficient for controlling access to data from a database table. The node concept and functionality has been extended so that functionality relating to nodes will also work now with entities.
Each content type consists of a number of fields that contain data. The Blog content type for example has just two fields containing the title and the body. We can easily add to the fields of an existing content type or create our own content types to fully customise our website.
A field contains data of a specific type so that a telephone number is a text field for example with a maximum number of characters specified in the field definition. A field is initially created for a particular content type but the data for each field is stored seperately and you can add the same field definition into another content type for example and will maintain the specifications set up originally.
You can add field types by installing additional modules. Two common types are the addressfield and the media field which let you specify address information or upload pictures and videos to your site.
Create a new Content Type
You can create a new content type if you are logged in as the site administrator from the Structure-Content Types page. Click on the Add new Content Type link and give your new type a name. In this case we are going to make a content type for each of our offices around the UK and define fields to show the name of the office with a contact name and telephone number and also allow for a picture of each office to be uploaded.
You can change the default settings for the content type to suppress the ability to add comments and so on.
Save the content type with the option to add some fields or you can edit the content type and use the manage fields tab to add your new fields. In this case we will add a text field for the name of the contact and a Photo field to add a picture of each office.
Fields are defined globally within Drupal and have many options you can set against them. It is possible for example for the an image field to set up the ability to add multiple photos for a single field so you can have several pictures for each node or to change the default display from a thumbnail to a larger format size. Thus you can define a field and use the field definition again in another content type if you want to keep similar characteristics for the fields on different nodes. In this case we accept the default values to create our Office content type.
Editing the content type also give us control over the display of the fields on the page. There are two tabs here, one for the full display of the node itself and one for the teaser which is what might be seen from the front page or a page showing a listing of all offices.
LAB - CREATE A CONTENT TYPE
Think of a content type you might want to create and write down the fields that it might contain. There are several default field types installed with Drupal including image, text, and numbers so you may find there is enough for you to implement your type. It is possible to download additional field types as you will see in a later session but for now you have to stick to what is available.
Once you have designed your content type (with just a few fields), try and add it into the website and set the content type settings as appropriate. Now some content and view the content as a guest user (the content should appear on the front page or you may have added it to the main menu).
The example we use in the training site is an Office content type for storing the location details of all our offices around teh country. It has the following fields:
Title - which is the office name (Brighton Office).
Manager - the name of the primary contact at the office.
Telephone - a text field for the phone number.
Location - we are using the body to hold the address and any instructions.
Photo - a single photo of the office stored in an image field.