EnglishFrenchGermanSpainItalian DutchRussianPortugueseJapaneseKorean

Google Search

Custom Search

Wednesday, May 5, 2010

Working with content types and fields (Drupal 6 and earlier)

The Content Construction Kitallows you to add custom fields to custom content types using a web interface. In Drupal 5.x, custom content types can be created in Drupal core, and the Content Construction Kit allows you to add custom fields to any content type. In Drupal 7 and later, most of the functionality of CCK has been absorbed into Drupal core. For more information on fields in core, see Working with Fields (Drupal 7 and later)

Documentation and instructions are available in the separate CCK Handbook.

Summary - Why would I need CCK?

Drupal comes with core content types like story and blog. For each content type, I can go to 'create content' and submit a new story, blog entry, etc. That's great if I can tailor my content needs to fit those models of pure chunks of text with or without attachments.

But say I want my users to be able to submit reviews of their favorite aardvark. That's a content type that's sort of a story, but I want to be able to display other stuff as well as a chunk of text for every node of that type, and I don't want it to be just attached file links.

My options: I could hack the heck out of the story.module, OR I could see if someone generous has already created an aardvark.module for the exact type of content I want, OR using CCK I could create a new content type called Aardvark Review.

Using CCK, I can create a content type that has exactly the fields I need, no more or less. My Aardvark Review for instance might have:
text field (comments on the aardvark)
dropdown menu (aardvark color)
audio file (recording of my aardvark's cheerful grunting)
image (photo of aardvark)

The CCK admin interface for creating these new content types is nice and easy: you basically just create your new type and then click through, adding the type of fields you want it to have and what their parameters will be (how much text for the review? which dropdown colors in the menu?). There are many add-ons available in the downloads section under CCK that add new kinds of fields to your options (video field! audio field! calculated values! and vastly more complicated ones).

From the users' perspective, they'll just click on create content>>aardvark review and get a form that asks them to submit their review, the aardvark's color, a recording, and picture. Voila!

Masukkan Code ini K1-EY8895-E
untuk berbelanja di KutuKutuBuku.com