CCK Module Basics
Content Construction Kit (CCK) is one the most important and at the same time most mystifying features of the Drupal platform. In this drop I'll provide a high level overview explanation of CCK and why you might want to use it on your site.
What is CCK?
CCK is a contributed module that allows you to:
- Add fields to an existing Drupal content type
- Create new custom content types
Drupal Content Types
It's important to understand a bit about Drupal content types. Drupal comes standard with blog, page and story content types. The main difference between these content types is the way they are organized by the system.
- Blogs are associated with a particular user and will be listed at 'http://www.yoursite.com/blog' which shows all blog posts by all users. Blogs will also be listed on page that shows only posts by a particular user. The url for those pages may be something like 'http://www.yoursite.com/blogs/[username]'.
- Pages will simply have a url " and not show up in any lists unless you take some sort of action to do add them to a list.
- Stories are like pages except that they are automatically promoted to the front page.
The common thread across these three types of content types is that by default they contain two fields called Title and Body. But what if you want to expand a content type to add more fields? That's where CCK comes in.
Adding Fields
CCK allows you to add one or more fields to an existing content type. There are a number of reasons why you might want to do that. You could add fields to improve your workflow. If you're publishing video you might want to add a link to the video each time you post. Adding a field that is required when you submit ensures that you won't forget to add the link. See my post Adding Fields With CCK for an example.
You could also add a field to make it easier for you to organize or theme your content later. When a piece of information is entered into the body field you can't really sort that piece of information or use it if you want to create a list using views. But once a piece of information has it's own field you have much more flexibility. Using the video publishing as an example once again you might add a field that displays the duration of a video that is linked to a post.
Creating New Content Types
If you want ultimate flexibility in customizing your content types then you can use CCK to create a whole new content type that meets your specifications. Imagine that you want to be able to add information about your favorite DVDs to your Drupal site. The title and body fields probably won't meet your needs. You might want fields that list the Director of the movie, the top stars, release date, rating, an image, a link to the trailer and more. CCK was tailor made for things like this.
How Does CCK Work?
Many people are confused about how exactly to put CCK to use on their own website. You get started by downloading the module from http://drupal.org/project/cck but you will likely have to do more. The power of CCK is in the types of fields that it allows you to add to a content type. The contributed module includes several standard fields (like text and node reference) included but many of the fields you would want to add to your content type must be downloaded and enabled separately.
Here are some additional fields that are listed on the CCK module page on Drupal.org:
- Computed field: lets you add a PHP-driven "computed field" to CCK node types
- Date: creates an ISO or unix timestamp date field
- Email: validated email field
- Image field: an image field
- Link: a URL field
There are many other fields that you could use to customize your content type. These can be found in the CCK modules section on Drupal.org. Some of the interesting fields that you might want to add are listen below.
- Addresses
- Fivestar (content ratings)
- Slideshow Creator
- Video Upload (for YouTube)
What Next?
Your new content type is basically a list of fields that are ordered a certain way. Creating a new content type and adding fields is only part of the work you'll need to do in order to make CCK work for you on your Drupal site. Each field that you add has settings that must be attended to. You may also be concerned with how the new content type is displayed when you publish a node. The Contemplate module allows you to adjust the layout and customize the appearance of content types. If the content type you have created is brand new then you will need to use the Views module to create a page, block or RSS feed for the content.
Another thing to consider when creating a new content type is the path to the nodes that you create. By default content created on your Drupal site will have a path that looks something like 'http://www.yoursite.com/node/24'. If you're submitting the DVD content type that I mentioned above you might want to the path to be something like 'http://www.yoursite.com/dvd/[movie-title]. That's why I highly recommend the PathAuto module for automatic node url creation.
CCK Screenshots
These are screenshots that show what CCK features look like in the adminstration section of this site.
- learnbythedrop's blog
- Login to post comments
- 81041 reads

Comments
CCK does not create content types
Thks for the writeup.
Please do not carry this common miscunception, though : since D5, custom content types are handled by core's node.module, not CCK, which 'just' lets you add fields on the content types that exist on your site.
You don't need CCK to create content types, and the expression 'a CCK content type' that pops up frequently (not in your paper, though), has no meaning.
It's true that you can create
It's true that you can create a new content type with the core features. But the new content type you create via the core functionality is still limited to the title + body structure until you add the features provided by CCK into the mix. There are other types of modules and techniques that a person could use to customize a new content type but I've found CCK to be the one that works best for a non-programmer like me.
This is a useful technical
This is a useful technical clarification. I had forgotten this, although I vaguely recall the issue on d.o
But I am not sure it makes any difference to end users because if a non-programmer wanted to create a new content type for a site, CCK is how they would do it.
Does not make that much
Does not make that much difference in the end, except :
- it's always best to give users the real picture of who does what - does pay on their overall drupal mojo.
- managing CCK issue queue, I get to redirect issues and say "CCK doesn't handle content types" at least 5 times a week and I really could do without :-)
How to change type of content?
Hello, Thanks for creating a very useful site.
The CCK basics should include how to change content type such as a content type created as "page" to "story"
Also a guidance on how to include the field for taxonomy in content type such as "page"
Good luck for your efforts
One thing I keep struggling
One thing I keep struggling to do with CCK is just add plain text on the page.
For example, I'm making a Job Application content type, and am using the File Attaachments area for people to upload resumes.
How can I add instructions that say like:
Use the file attachment tool below to upload a Resume and Cover Letter.
I'm looking for just a field type of "plain text (not really a field at all)"
any suggestions?!
thanks again!
Text Fields
A plain text field is really a field. When adding you select a field type of "text" and choose either the text field or text area (multiple rows) widget choice in the drop down box next to the "text" field choice. You can fill out a default text for the field and then after saving the new field you have added you can go to /admin/user/permissions and allow users to view but not edit the field. Then you will have an additional field with the text that you want on your submission form.
Thanks for the reply! - but
Thanks for the reply! - but that doesn't seem to work. When I make it so they can't edit the field (even when they CAN view it), it doesn't get displayed on the Create Content form. :/
You are talking about while using the Content Permissions module, right?
No, I wasn't referring to the
No, I wasn't referring to the content permissions module, just the standard features within CCK. The easiest ways to add instructions for any field is to use the "Help Text" field that is displayed in the configuration for any field that you add using CCK.
Help Text
On the page "Home » Administer » Content management » " click on the tab "Manage Fields. Below you will find a field called "Help Text". _It's_ help-text says "Instructions to present to the user below this field on the editing form." That's where you would type "Use the file attachment tool below to upload a Resume and Cover Letter.". That's what your user will see when he/she uses the form on the page node/add/.
Of course, if you want this text to appear _above_ the field, rather than below, you will have to do a little more work and modify whatever theme template or theme function generates the HTML output for that field and label.
Hope that helps.
Great review
I'm pretty new to Drupal and am still learning about these core modules. Your review was the easiest to understand, now I finally know what this so talked CCK is about.
Unfortunately I wasn't able yet to make a few fields I created to be shown on posts edition page.
Field Groups
Hi, thanks for posting your information.
I have created a standard field group consisting of an image upload and a node reference link. I would like to duplicate this group with differenct images and links in the same content type or node. I can't seem to figure it out.
Any help will be greatly appreciated.
Thanks in advance.
Links to your created Content
Hi!,
I have a query. If I have a content type name patient profile and I create several contents of that Profile, how can I view the list of all the patients as links on a page or in a block or anywhere else?
Thanks
Creating Lists From Content
You would want to use the views module (http://drupal.org/project/views) to create a list for that content type. See http://learnbythedrop.com/cckandviews and http://learnbythedrop.com/drop/139 for more information on how to do this.
How to modify the look and feel of the content
Hi again!
Thanks for the reply it really helped me out. I have another query. As I have already mentioned that I have a content type Patient Profile (PP). Now when I view a content after creating a content of type PP, it gives me a ugly look. I used inline mode of display fields but still the fields are too closed and the look is not good.
How can I customize the Patient Profile Content type or anything else that whenever I create a new PP content, it should have render a neat and clean and elegant display, to whoever views it?
Best Regards
FAS
Contemplate Module
The contemplate module (http://drupal.org/project/contemplate) allows you to customize the look of content types without having to modify template files.
This is awesome! Thank you so
This is awesome! Thank you so much for the clear, concise information. Now I get what all the fuss is about over CCK.
Creating New Content Types Videos
This is great! I know you already went over this but i kinda need it broken down for me...what I'm looking to do is create a site where I can let users view videos...if you've seen other video site I'd like something similar where I could categorize the videos and then once the user selected a category they would see a page that has multiple images with links to the actual videos... I also want the users to be able to upload videos of there owen as well...you made reference of this above but didn't really mention what other specific module was needed to complement the CCK... I'm not only new to Drupal but I'm also new to web design as a whole...basically I just need help deciding what other modules I need...thanks a lot...
Video Directory
I think you probably need to spend a bit of time researching different Drupal modules and experimenting with them. A site like the one you're describing needs to be well thought out and should be built one function at a time. The first modules that I would look at are Video (http://drupal.org/project/video), Flash Video (http://drupal.org/project/flashvideo), Blue Droplet Video (http://drupal.org/project/bd_video) and Kaltura (http://drupal.org/project/kaltura).
IP Camera Vedio Stream
Hi Again!
Thanks for all the help. It is always worth visiting the site. I have a requirement here. I need a Live IP camera video stream page. What I want is that I want a link or a thumbnail image or anything on my user profile page which one clicked will take user to the Live IP Camera video stream. For example I have 3 rooms and the information about them is saved using Rooms content type. Now I want to add one more field in the content type where I want to insert the IP od the IP CAMERA installed in that room so that when I view that room's info I can also see it live. I searched many modules but was not successfull enoungh. Please help me in this regard.
Thanks and Regards
FAS
remove tags
Hi...
Thanks for the great series of lessons. I really appreciate your effort.
I want to know how to remove tabs. For example, the my account page (and lots of others) have tabs on the top whose numbers extend beyond the standard page size and the tabs even overlap with the navigation menu block on the right side. Many of these tabs are useless to me right now. How can I remove them for the users' sake and still have admin access to put it back if required?
Removing Tabs
I'm not sure what tabs you're referring to. Perhaps if you link to a screen capture of a page with the numbered tab enabled I can provide more assistance.
Here is the link to my cluttered page.
Here are the links to two of my pages. http://authenticityonline.in/. I'm especially worried about the top line (just below the admin menu bar: view, bookmarks etc.). I want to know how to remove open ids, contact, notifications, user permissions tabs. How do i do this?
2nd page - http://authenticityonline.in/node/add/book. here I want to know how to remove some fields like friend access, user relationships, url path etc.... how do i do this?
Removing Clutter
I can't really see what you're seeing because on the add book page you have to be authenticated to see that form. If you want to remove the login block, which I do see, you can go to the admin/build/block page and set the block location to and then users will not see the block at all. Or you can selectively remove the block from certain pages. Also if there are things that you don't want users to see and they don't need to use the features you can take away their permissions to access those features in the admin/user/permissions section.
Newslettee Templates
I am new to drupal and am planing to design web based newsletter templates using CCk module but i don't know how to do that. Does anyone have an idea of how i can achieve this?
upload/filefield
Hey Rob,
your tips are really helpful! I also activated cck and the file field. When I now use the file field in a content type it'll give me the possibility to upload a file, when I create a node of that specific content type. But I want to enable the users to upload a file without switching to the edit mode or creating that node. I want them to be able to upload it in the view mode. Is that possible too?
Thanks
Juergen
Upload Files in View Mode
I don't have an exact answer but rather an important question that relates to how you would accomplish it. What do you want to happen after the file gets uploaded? It sounds like you don't want a new node created. If that's the case then do you want the file attached to the current node? Or do you want the file merely uploaded to a directory?
Yes, I want it to be attached
Yes, I want it to be attached to the node, so that it appears on the node and can be downloaded by them. I know how to do this if I make them switch to the edit mode, but my goal is it to make it possible for registered users without switching to the edit mode. Any ideas?
Thanks
Juergen
Attaching Files To Nodes
I don't know of a module that specifically does this. All I can think of, and you would need to test it, is to create a content type with no title or body, and add the file upload field as the only field accessible to the user. You can make the body not available in the standard settings. And you could use the Auto Nodetitle module to hide the Node Title field. http://drupal.org/project/auto_nodetitle
Hi Rob!, Thanks for all the
Hi Rob!,
Thanks for all the tips. It's great being with you. I need some help in my website. I want to embedd Live Ip camera video in my page which I can do by simply pasting the code in the Text field with FUll HTML or PHP filter. Fine!. but I want the user to just enter the Ip of the camera in the Text box at the time of adding the content type (node/add) and the value of that text box should automatically be placed in the code. How can I achieve this?
Thanks
IP Camera
It sounds like you would need to define an input filter, similar to what they do with the Embedded Media Field module. http://drupal.org/project/emfield I don't know how to do that though. I suggest checking out the Embedded Media Field documentation to research the possibilities.
CCK Allowed Values List - Maximum Limit
For a CCK Text Field - Select List, what is the maximum number of options you can have in an "allowed values list"? Is it unlimited?
I am using CCK for D6.14.
Thanks
CCK Allowed Values
I don't know if there is a limit. The best way to see is to try and create the field with the number of allowed values that you want.
Newbie needs help installing CCK module
I have Drupal 6 running on a site hosted by GoDaddy, and have been working through the SAMS Teach Yourself Drupal in 24 Hours book by Jesse Feiler. All was going well until I tried to install CCK. I downloaded, unzipped etc... but some of the checkboxes on the modules page are checked but greyed out, and some of the empty checkboxes are uncheckable. I followed the enabling/permissions instructions as well as I could, but my Drupal installation was not behaving the way the book led me to believe it should. These Module checkboxes are checked, but greyed out: CCK Content, CCK Option Widgets. CCK Text. Also Other: Advanced Help (checked, greyed out) while Advanced help example is checked/uncheckable OK. CCK Filefield Meta is not checked, but greyed out and uncheckable. Can anyone help?
Installing CCK on GoDaddy
Sounds like a GoDaddy specific problem. You may want to try their forums or support to get help on this. The only other thing I can think of is to make sure that you have uploaded all of the files from the modules. Sometimes a file gets missed when uploading and causes problems.
create dependency between cck fields
Hi,
I am new to cck fields but i was able to mange to create a new content type and add some cck fields. question, how I can create dependency between those fields, e.g if a user select a certain value from the list box, another field will appear other wise keep it hide.
thanks
Nancy
CCK Field Dependency
I have never done this. There's some discussion on the topic on Drupal.org but I haven't found a module yet that can make it easy enough for a non-php developer to accomplish.
I was wondering if you've
I was wondering if you've come across a really good example or blog on creating a custom multifield repeating group... Not sure if that's a good way to describe it but I'm creating a newsletter and I'd like to build it up with
-- CCK Field Group ----------
header - textfield
content - textarea
-----------------------------
add new cck field group - button that repeats the above field group to build content
Any ideas or examples. An example module or code would be easier for me to understand but at this point any help would be great.
Thanks
Martin
Re: CCK Module Basics
Hey,
I'm a new to drupal. I'm tryin to make a job portal where I decided to have two content types a "profile for a job seeker" and "job posting" content type for employer.
I've created the CCK based form each of the two profiles but how do i display the user entered details when the user logins the second time. When user logs in the second time, I would like to show em manage profile link instead of create profile.
Any help would be appreciated. Thanks in advance. Hints are most welcome.
Also, thx learnbythedrop you ve made learning easy.
Re: CCK Module Basics - Conditional Menu Link
There are a couple of different ways to show or hide a link based on the status of a visitor to your site. How you hide it depends on how you integrate the link into your site in the first place. If you display your link in a block you can set the block using "role specific visibility settings" in the block settings. So you can place your link to manage the profile in a block that is only available to authenticated users. And you can place your link to create a profile in another block that only shows up for users who are not authenticated.
If someone is already authenticated then you would want to pass off the condition to different roles. For example you could create a role for people who have signed up but not created a profile and yet another role for those who have submitted a profile. I believe that the Rules module could assist with that.
A simpler alternative might be to use the Menu Roles module which, "...allows you to restrict access to menu items1 per roles." I've never used the module but it may be what you're looking for.
Re: CCK Module Basics
how do i post a content like blog on a page other than the front page??
Re: CCK Module Basics
Use the views module to create another page that will list the post or posts that you want to display. http://learnbythedrop.com/cckandviews
Re: CCK Module Basics
One thing that stumps me about CCK is: Why can't I create a content type that DOESN'T have a title? I suspect the technical reason is that all content is nodes, and the nodes table has a title field.
But suppose I want to create a type "library checkouts" which has a date, book node ID, and user ID. "Title" doesn't fit with this content type.
Seems like there would be plenty of other content types that don't need a Title.
Am I trying to shoehorn a database application into a CMS?
Re: CCK Module Basics
You can hide the title of the node form. There is a module called Automatic Nodetitles that can assist you with that. http://drupal.org/project/auto_nodetitle
Re: CCK Module Basics
Thanks for the informative post. Recently fell in love with Drupal and looking forward to diving into CCK.
Can't Get CCK to Create User-Entry Fields
I want to create a web page that allows users (including anonymous users)
to fill-in text boxes regarding their company information
(i.e. name, street address, email address, etc).
Then, I want to be able to produce a report that list the company information.
First, I tried using the Webform module.
That enabled me to easily create fields that users could fill-in.
But, then I discovered that the Views module doesn't have access to the data created by Webform.
So now I'm trying to use the CCK module to create the fields in which users will fill-in information,
and then I'll produce reports on that user-entered information using the Views module.
But I'm having problems making CCK fields accessible to users
so that users can fill-in those fields
(as if the fields were on a standard web page entry form).
I've set the Permissions for the CCK fields to make them accessible by anonymous users.
Incidentally, I'm using Drupal 6.
I greatly appreciate your help.
Re: Can't Get CCK to Create User-Entry Fields
There are a couple of levels of permissions involved with what you're trying to do. You have to give anonymous users access to the node type and then if you are using CCK Permissions you must set the access to the fields that you add to the form. Look in the "node module" section on the user permissions page and check to see that anonymous users have the ability to "create" the new content type that you created.
Re: Can't Get CCK to Create User-Entry Fields
Thanks for your help.
I enabled all the permissions as you described, and that didn't address my issue. Then as an experiment on my test site, I gave anonymous users all permissions, and that still didn't address my issue.
So I'm starting to think that CCK is not the module to do what I want to do...
I want to create a node that will enable an anonymous user to fill-in fields (i.e. company name, email address, etc), and I want that user input into those fields to be accessible using Views.
Apparently, the Webform module won't work for this because the input to fields created using Webform are not accessible by the Views module.
It seems like CCK will create fields that are accessible for input only in "edit mode", so if anonymous users aren't given the Permission to edit the content type, then they can enter input into the fields created with CCK. Moreover, when I give anonymous users the Permission to edit the content type, then they have access to edit ALL the content type's fields in "edit mode" (not just the fields that I created using CCK).
This most be a common need for Drupal website developer:
create a form that anonymous users can fill-out, and
have the resulting data accessible view the Views module.
Thanks again for your help!
Re: Can't Get CCK to Create User-Entry Fields
I'm very sure that CCK can do what you want it to do. I've created contact forms and submission pages for other sites using CCK instead of Webform. I believe that you can give users permission to edit the content type without compromising previously created content. So if that's standing in your way then enable it and test it out. There should be a setting for each node type that starts with "Edit own ... content". If you don't publish the submitted node, or don't enable view access then people will not be able to edit previously submitted content.
I can think of one other option if you feel that webform is your only choice. The Table Wizard module (http://drupal.org/project/tw) gives you access to any existing table in the Drupal database, and it integrates with Views so you can display it.
Re: CCK Module Basics
Hello. I am also stumped when it comes to creating contact forms with cck. The fields that i create are not displayed on the node that i published. They are just extra fields in the backend when editing a node. I am also trying to make it as to were a user can just type the data into the textfield without having to sign in or use the edit page button. I am also racking my brain trying to figure out how to put together a contact us form with cck.
Re: CCK Module Basics
It sounds like Webform (http://drupal.org/project/webform) would be a better option for what you are trying to do.
Re: Can't edit certain fields
Hello.
Great site! I've taken over a forgotten site with CCK fields used in various forms on the site. Some fields in these content types are marked as 'Node module form' and have no editing links and I need to edit them. I was able to edit the ones marked 'Taxonomy module form' by editing the taxonomy name itself but had no such luck with the 'Node module form' types.
I don't have access to the original coder so that's out.
Any help would be great.
Thanks in advance
Re: Can't edit certain fields
Those fields are controlled by the content type so in order to edit the attributes of those fields you need to edit the content type. In some cases you may need to use a contributed module to modify the core node form fields. The Automatic Node Title module (http://drupal.org/project/auto_nodetitle) is an example of a module that can make changes to the core node form fields.