Content Construction Kit (CCK)
CCK Handbook on drupal.org | Video of CCK class at Linuxfest
Some CCK Modules or at CCK at Drupal Modules (select CCK as category)
We're going to create some custom tables for a Photography school.
We will create some new Content Types and some new Taxonomy so that we can display a table called Upcoming Classes.
What we want to see in our drupal site - the Course links go to a description of the course, the instructor links go to more detail about the instructor:
Upcoming Classes
| Date / Time | Course | Location | Instructor |
|---|---|---|---|
| 6/10/2008 4 pm | Photographing Water Views | BayView Cafe | Anne Avery |
| 6/24/2008 10 am | Digital Darkroom | Haggard Hall 155 | Robin Smith |
| 7/4/2008 8 pm | TimeLapse Photography: Fireworks | BayView Cafe | Brian Bellevue |
Instructions
Install and Enable
Install some new modules - get these from drupal.org:
- CCK
- Views
- Date
- Calendar
Enable the modules. If you get a "permission denied" message, go to sites/all/modules/views and change permissions to 755 on the folder and its child folders.
Categories and Content Creation
Create New Taxonomy
Admin> Content Mgmnt>
Taxonomy > Add Vocab
Add Terms
- Composition
- Landscape Photography
- Traditional Dark Room Techniques
- Digital Darkroom
- Name = Instructor
- Type = instructor (always lower case, no spaces)
- Title Field label = Full Name
- Body Field label = Bio
- First Name (useful)
- Last Name (so we can alphabetize)
- Compentency (multiple choice from Subject)
- ClassName - use Title Field and change label
- Description - use Body Field and change label
- Class_Time
- Class_Instructor
- Class_Location
Create Category called Subject
don't worry about Content Type to apply these to yet.
then Add Terms (or similar):
Create Content Types
Content Types>
Add ContentTypes>
Create two new content types called Teacher and Class
NOTE: name the fields distinctively so you'll be able recognize them in a list of all fields in the system presented when defining a view.
First Add Content Type:
Then expand Submission Form settings. Note that Title and Body are required - but sometimes need to be renamed to make sense to the person who inputs data.
Then expand Workflow Settings. Deselect Promoted to Front Page if you're depending on a view to display these. For Comment Settings - probably only applicable to opinion pieces, probably disable this for teachers.
Submit this and it creates a new Content Type.
--> Repeat for "Course" but use Course Name for title field and Course Description for Body field.
Modify Custom Content Types
Go back to the list of Content Types and select the Instructor you just finished creating. Select Manage Fields. Note that Full Name and Bio are already there, but we need to add some additional fields.
Content Types>
(select type) >Manage Fields
Teacher has these additional fields (text, required):
Class has these fields:
Modify Taxonomy
Admin> Content Mgmnt>
Taxonomy>
Select "Subject">Edit Vocabulary
Under Types:
select "Instructor" and "Course"
Go back to Taxonomy, edit Vocabulary for "Subject" to indicate that these terms should be applied to Content Types Course and Instructor. You couldn't do this when you created the Taxonomy because you hadn't created the new Content Types yet.
By adding this, you make sure that when you create a Teacher you are allowed to indicate which subjects they can teach; when you create a class you are allowed to indicate which subject they are related to.
Content> Create Content>
Instructor
and then do the same for Course
Create Content
Make up some Instructors and some Courses. Notice that Subject appears as one of the data pieces to enter because you indicated in Taxonomy that it belongs to these content types.
