Setting up your Content Types with CCK module

This lesson will use a sample CCK Content Type called "Article". You can create or import this Content Type to follow along (grab the import code from below ***ADD CODE***), or else simply apply the concepts to your own content types. Before beginning on your own home page, it is important that you fully develop the Content Types you will be using for your site (or at the least, those that will be involved with the home page in any way). Since your Content Types make up the bulk of what your home page will actually consist of, it's important to have them all sorted out before dealing with your home page. If you'd like some guidance on setting up your own Content Types and fields before proceeding with this lesson, please visit the following resources:
-
 -

For simplicity, our sample Article content type will have the following fields:

  • title (standard Title field)
  • body (standard Body field)
  • teaser_title (text field, set with a maximum of 50 characters)
  • teaser_text (text field, set with a maximum length of 100 characters)

(your Content Types may have considerably more fields, or additional types such as Image fields)

You might wonder why you need the teaser_title and teaser_text fields, instead of just using Drupal's own node title and automatically generated teaser text. On a more complex home page, it becomes important to ensure that certain blocks of content will always consistently fit into the specific amount of space that's been allotted to them (enforced during entry of the content with the field's "maximum length" setting). On more professional sites, a short "synopsis" of each item of content is generally preferable to an auto-generated chunk of text cropped off of the beginning of the full content's page, which is Drupal's default behavior. Having a separate teaser_title is more optional, but if you choose to have one, will allow you to set a different or shorter version of the title to more easily fit into the confines of the home page, while still allowing you to have a full length title for the actual page. Setting up dedicated text fields in CCK for the teaser and title helps to accomplish all of these purposes.

If you prefer to go "all out" with your Article content type, here are some additional field options to choose from (including these just for your reference/ideas - they are not used in the lesson):

  • article_date (text or date field - if this is an online version of a printed article, this could hold the date the article was actually published - rather than the date the content was added to Drupal)
  • sub_title (text field - a short sub-title, as is often seen on articles)
  • author_name (text field - as this is probably a different name than the admin account publishing the content)
  • article_image (imagefield - the main image for the article... using Imagecache module, it would be scaled and cropped to make the teaser image, the primary image at the top of the article page, and also could be used to create thumbnail images to display in other contexts throughout the site)

When your Article content type is fully completed, your editor/staff will just need to click Create Content -> Article, and be presented with exactly all of the fields they need to fill out and images to upload to completely and correctly produce an article (with no coding - other than maybe light HTML for the article formatting itself unless you give them a WYSIWYG editor).