Book Image

Drupal Multimedia

Book Image

Drupal Multimedia

Overview of this book

Table of Contents (16 chapters)

Content Construction Kit (CCK)


The CCK module is a valuable contributed module that can be found on a large majority of Drupal sites. In fact, parts of it are increasingly becoming integrated into Drupal core because of its power and versatility.

As discussed earlier, content is largely defined on a site by content types for nodes. For instance, modules may be activated to provide blog, page, or video-type nodes. Using CCK, you can also define custom types for a specific purpose.

As an example you might define an article content-type, which in addition to the title and body fields automatically provided, might include a byline field, a teaser Image, and an issue reference.

As with all contributed modules, you will first need to download and install the module before using it on your site. The CCK module is available at http://drupal.org/project/cck. Once downloaded, you will need to place the entire extracted folder in the /sites/all/modules directory. After this, you will see the module along with all other available modules for a site by browsing to Administer | Site Building | Modules (at /admin/build/modules ).

Enable that module and any other desired modules included in the CCK package of that screen such as Text, Number, or Node Reference. (In Drupal 5, that section is named Content.)

Custom Content Types

Now you will be able to create your own custom content types. Continuing with the example of an Article type, you would browse to Administer | Content management | Content types | Add content type (at /admin/content/types/add) and fill in the appropriate fields on that page. After submitting, you would have a new content type with a title and an optional body:

Fields

The strength of CCK is that it allows custom fields to be defined and added to the content types. Fields allow you to add any additional information to a type such as subtitles, images, and videos. Some basic fields, such as text and numbers, are included with the module. But others, such as images and files, require additional contributed modules.

To add fields, you will need to click on the add field link next to the new type on the resulting page from our ongoing example:

In this example, that would bring you to /admin/content/node-type/article/add_field). You'll name the field, select the type of field such as text or image, and submit the page to see the configuration page for the field. Here you can further define things such as setting a maximum image resolution or allowed values. In this example, we'll create a text field named Subtitle:

The resulting page contains sections that will affect the specific field. Additionally, because created fields can be shared among content types, you can further define settings that will affect all similarly shared fields.

Once a field has been created, you may change the order of its display by dragging the icon to the left of the field on the resulting page, which you can also find by browsing to Administer | Content management | Article | Manage fields (at admin/content/node-type/article/fields ):

User Permissions

We can define permissions for our users, who can be grouped by roles. For instance, we might have an edit role, whose users are able to create article content. First, we'll define a new role by going to Administer | User management | Roles (at /admin/user/roles ):

You would then visit the User Permissions settings browsing to Administer | User management | Permissions (at /admin/user/permissions), where you can set permissions for various roles such as allowing editors to create article content. You will see the permissions for all content types under the node module section of the form.

Note

In Drupal 5, the Permissions page was known as Access Control, and could be found by browsing to Administer | User management | Access control (at /admin/user/access).

To give a user the new role, we would then need to edit his or her user account. We can find a list of recent users at Administer | User management | Users (at admin/user/user), where we can edit them:

Creating Content

Once you have created a new content type and set its permissions, you may create new content of that type by browsing to Create content and clicking on the new type (in this case at /node/add/article ):