Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
CCK is deceptively simple. All it does is let you add fields to content types. But as they say large streams from little fountains flow and tall oaks from little acorns grow. And now Drupal. org hosts over a hundred modules that support and extend CCK. We'll peak at some of those contributed modules in other videos. But before we do that, let's take a look at some of the neat features that come with the core CCK download itself. Because we're going to be creating and destroying a lot of fields in the process, we're first going to create a new content type called Temp. To do that, go to Administer, Content management and Content types and of course Add content type. The name will be Temp, type will be Temp and I'll just write Delete this when done as reminder. Scroll to the bottom and save it.
When we first downloaded an enabled CCK, you probably noticed that the package actually contains several other individual modules. Only the content one is necessary. It's really the core of CCK. The others are all optional. Although if you don't turn on, at least, the text module, then CCK doesn't really do much else. We're going to turn on some of those other modules now. We'll start with one that gives you additional ways of entering information called Option Widgets. To get there, you go to Administer, Site building and Modules and there is our CCK group, right there at the top. We turn on Option Widgets and scroll to the bottom of the screen and click Save configuration.
Now let's go back to that Temp content type we just created. To do so, click on Administer, Content management, Content types and the Temp field is right here. We're actually going to manage those fields. So we'll click on Manage fields and we'll add starting here. I'm going to add a filed I'll just call funky text field and I'll call it funky right here. The type once again will be text because that's our only option, but watch what happens. Now instead of just having text fields available, you can also have check boxes, radio buttons, a select list and so forth. We won't be looking at all of these. I assume you already know what some of them are and if you don't, you can go poke through these options at your own leisure. But I'll show you just one of them, the Check boxes/radio button option. So I select that and click on Save.
Now let's take a look at some of the options that we have here. The first thing that we see is a warning box at the top saying that we need to specify allowed values for the field which makes a lot of sense. If you think about check boxes that you have seen before, you have to have options to choose. So if we scroll down, we see our allowed values list here. We enter one value per line. In fact we could have values that are different from the label that they hold. So for example, we could have Cat=1, Dog=2 and so forth. We're not going to get that fancy. We'll just have cat and dog and bird, like so. We'll ignore the rest of the settings and go to the bottom and click Save field and we have our field there. Now we don't see what this means until we try to create the content of Temp content type, scroll down to that field and there it is. We can choose from cat, dog, bird, or none of the above. Let's not actually create that node, but instead go back and take a look at the content type.
Again we click on Administer, Content management and Content types and Manage fields. If we want to edit that field and look at some of the other options, we click on Configure. You can see we can change among other things the number of values that are permitted. This is an interesting setting specifically for check boxes because that's what determines whether they're radio buttons or check boxes. If you change it to something other than one, it becomes check boxes, since obviously the definition of a radio button is only one can be selected at a time. You can also say whether it's a required field when someone creates the node and so forth. Again I won't go through all of these settings. They're fairly obvious to just look through and try out yourself.
So that's Option Widgets. Let's go back to our modules and see what the other CCK modules are. To do so, we go back up here, Administer, Building, Modules and scroll down so we see our CCK modules available. The next one we'll look at is field group. Enable it and scroll to the bottom and then click Save configuration. Once again we'll go back and we'll take a look at our content type called Temp and manage fields. I'm going to create some more fields. The first one I'll just call Field1.
These are going to be very simple fields. Remember we're going to delete this content type when we're done. So we won't actually hurt anything by adding these fields. I'll just call it a text field, select list and make it plain text and say Save. I'll just save at the bottom. I'm going to create a couple more fields. Field2, Field2, Text and Text. Actually that's enough. We now have three fields. We can put that into a group if we wanted by creating a group down here. We'll call that Extra fields and the group is called extra_fields. Again we have the human readable name and the machine-readable name with all the rules that implies, click on Save. Now we can actually create a field group by dragging our fields into that Extra fields area. Do it like that and save. When we create a note of that Temp content type now by going to Create content and Temp, you see what that actually means. Scroll down. It creates this little box for our fields to live in.
That's actually fairly handy especially if you have a long form. We go back to our administration page for the modules and scroll down again. I'm going to turn on one more called Content copy. Click it on. Go to the bottom of the page and save the configuration. Now we'll go back to the content type Temp. Once again by going to Administer > Content management > Content types. We see up here some additional choices: export and import. This will actually let us get our content types out of one Drupal installation and into another. Very handy if you're managing many sites.
The last one we'll take a look at is called Content permissions, but with a caveat. You can get yourself into a lot of trouble with this one because it complicates who can see and edit nodes quite a bit. By default all fields are hidden when you turn this module on, whereas before they were all showing. That can really mess you up. So we'll turn it on and take a quick look at its controls. But then we're going to turn it off again. Once again we get there by going to Administer, Site building and Modules, scroll down to Content permissions, turn it on, save and we're done.
The next thing we do is configure your Fields permissions. It actually gives us a link at the top, or you could go there by going to Administer, User management, Permissions. As we scroll down here, you see we now have this extra set of permissions, which allows people to edit and view the fields we created, but they're all turned off. So even though we created those fields, they will be invisible to everybody. Once again very dangerous but also very powerful and incredibly useful if you're doing some security conscious site. Many sites that deal with personal information are security conscious. So it's very good to know about this module even if you only use it with great care. Once again I'm going to go back to Modules with Administer, Site building and Modules and be sure to turn that one off and save.
Before we go, let's clean up some of the mess we created. Go back to Content management and Content types. Since we didn't create any nodes of that content type, we can just delete it and be done with it. If we had created any nodes of that content type, those nodes would remain in Drupal, but they wouldn't be editable. That's very difficult to deal with. If you ever come across that, by the way, you'll have to go into the SQL database and make changes there in order to make those nodes editable again. Well, congratulations! You now have thoroughly schooled in the basics of the Content Construction Kit, which as you've seen has a lot of complicated and hard to find details. I would guess that most people who use it don't know nearly as much about it as you do, now that we've discussed them in the past few videos. Certainly I didn't until I've been using Drupal for about a year and I was surprised that how many common presentation problems are easy to solve once you have this knowledge.
Get unlimited access to all courses for just $25/month.Become a member
58 Video lessons · 61461 Viewers
61 Video lessons · 93604 Viewers
82 Video lessons · 104396 Viewers
56 Video lessons · 107899 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.