Friday, February 27, 2009

Introduction to CCK

Introduction to CCK

Presentation on Sunday 20 July 2008
at 11:00 AM

Presenters
Alan Palazzolo
Description
This presentation aims to give a basic understanding of the powerful Drupal Module, CCK (Content Construction Kit). This module is so powerful in fact it is supposed to be in Drupal 7 core (meaning it will come with Drupal itself). Basically CCK allows site administrators to add fields to a content type other than the usual Title and Body. This presentation will begin with a brief overview of Drupal basics like nodes and content types. We will then cover the core CCK module, then dive into modules that extend CCK. Please feel free to ask questions.

Prerequisites
This presentation will use Drupal 5 modules. The same basic principles apply for Drupal 6 but the details can vary. And, as of this presentation CCK for Drupal 6 is not stable (but close).

Drupal Basics
Node
The term node in Drupal is a very abstract concept. The Node Module which handles nodes is a core module in Drupal, meaning that it works just like any other module but is required for Drupal to function. A node is any piece of content. (The other main pieces in Drupal are Blocks, Comments, and Users.) By default, a node simply holds a title and a body. In Drupal core, we can define different types of nodes.

Content Types
Drupal separates different types of nodes into content types. By default, Drupal comes with the page and story content types. Really the only difference in these two content types is that a story gets promoted to the front page and allows for comments; otherwise there is no actual difference. Drupal allows site administrators to add different content types. This is really helpful (and necessary) to organize content in a meaningful manner for your site. Also, by default Drupal allows for access management based on content type, so different content types will help with security.

Content types basically become your input forms for content. This could mean that you have a content type for a blog post that only bloggers can create. You may also have a content type for Movie Reviews that you only want registered users to create. By default, both these input forms (content types) will only have a title and a body.

But what if you want your Movie Review to include the movie title that it is referring to; then you want that movie title to be formatted a specific way. This is where CCK comes in. Without CCK, you would either have to develop a module that explicitly creates a new input for the movie title, or you would have to depend on the user to format the body of the node in a specific manner. Both are less than ideal.

CCK
CCK allows the site administrator, through the web interface, to create custom fields for any content type. This means that we can easily create a text-field for the movie title of the Movie Review content type. This new text-field allows for the content creator to have a more focused input mechanism and allows for the end user to have a well-formatted display.

Field Types and Widgets
In this context of CCK, text is a field type. Field types are types of data that are collected for a content type; for example, this could be text, an integer, a node ID, latitude and longitude. The base install of CCK comes with a number of field types such as text, integer, nodereference. Field types are not restricted to a single piece of data.

Widgets are the objects or mechanisms that these field types are gathered with and possibly displayed. For example, you could collect text data through a text-field, text-area, a drop-down menu, etc. You could also collect latitude and longitude data with two text-fields or through a web map.

Also, once you have defined a field type for a specific content type, CCK makes it easy to simply add that field type to a different content type.

Management and Display
Within each content type, CKK allows you to group different fields together and assign order by using the usual Drupal weighting system.

CCK also allows you to determine how each field within each content type will be displayed for either the teaser or full views of each node. CCK allows for modules to define different types of views for different field types. For example, and image field type can display an image at one resolution for the teaser view and a different resolution for the full view.

CCK, Extended
There are huge number of CCK Related Modules for Drupal. The following modules are some important or interesting ones that extend CCK in a number of ways. Together we will install and take a look at the functionality of each. Please click on each link to get a detailed description of each.

Computed Field
Date
Email
Image Field
Link
AJAX Select
File Field
CCK Blocks
CCK Currency
CCK Field Permission (Integrated into CCK for Drupal 6)
CCK Map
Education Field

Phone
Related Modules
The following modules do not actually create any different CCK field types but are important on how CCK is accessed and displayed.

Node Profile
ConTemplate
Theming
This presentation will not go into theming CCK fields, but Chach Sikes will be giving a presentation entitled Theming CCK: working with fields, content types and template files at 3:00PM on Sunday July 20, 2008 which will cover this topic in detail

No comments: