Drupal Content Types

Content Types are really the heart of how Drupal stores and organizes information. A content type is a definition of a kind of information that a site can store. For example, you can have a content type that defines what a "Job Posting" is like, or what a "Blog Entry" is like, or what a "Hotel Room" contains, and so on.

Some modules will add content types automatically, such as the Event, Image, Forum, Book, and Blog modules. But when you need a "non-standard" content type (which is probably more often than not), you will probably find that the Content Construction Kit (CCK) is the way to go.

The CCK is a module for Drupal that allows you to construct your own content types. For example, on the BYU iOscars site I rebuilt, I created a content type called "Movie". A movie type defines a title, a director, a year, an abstract, some awards given (if any), the actual URL of the movie, and URL for a thumbnail of the movie. Whenever I add a new movie to the site, I fill in these fields and they're displayed on the page.

One of the wonderful advantages of the CCK is that there is a plethora of modules that add new kinds of fields that you can add, such as a field for email address, dates and times, references to other content or views, hidden numbers, addresses, monetary values, media objects (pictures, videos, audio, etc), and so on. Just download the modules, unzip them, add them to your sites/all/modules folder, and enable them. From there, you can create new content types, add new fields or almost any kind you can think of, and off you go.

If, for example, we wanted to create a content type describing a room in a hotel, we would do the following:

  1. Create a new content type which we'll call "Hotel Room"
  2. Add a number field for maximum number of occupants (this would probably be most simply displayed a select list)
  3. Add a number field for the number of beds available
  4. Add a money field for the cost of the room per night
  5. Add some checkboxes to describe what features are available, such as Cable TV, Wireless Internet, and so on

That's a very basic outline of a hotel room, but we can see that it's somewhat accurate and helps us understand the power of content types.