Last updated December 13, 2007. Created by danielskeenan on December 13, 2007.
Log in to edit this page.
This is an outline of a screencast available for viewing here and downloading here.
Table of Contents
- What is CCK?
- How do I use CCK?
- Can I hide certain fields from the teaser and/or page views?
- How do I create node template files?
- Outline used in the Screencast
What is CCK?
CCK Stands for Content Construction Kit. It allows you to expand content types using different fields that may pertain to it. For example, In the Video Game Review Site created in the Demo, Different fields were added for things like Game Ratings.
How do I use CCK?
You can use CCK in any custom content type simply by going to the "Fields" Tab in the Add/Edit Content Type Page. If the default number of fields are not enough, you can download more from here.
Can I hide certain fields from the teaser and/or page views?
Yes! This is done from the "Display Fields" tab in the Add/Edit Content Type Page. Here, you can also change were the label is displayed, as well as hide the label entirely.
How do I create node template files?
Node template files are placed in your theme's directory (i.e. If you're using Garland, it would go into the themes/garland directory) and is named like node-contenttype.tpl.php. More information can be found in the handbook here. Specifically, you may be interested in a list of variables you can use in these files. Also, look at the node-gamereview.tpl.php file used in the demo.
Outline used in the Screencast
- "CCK, the Content Construction Kit, Allows you to expand Content Types beyond the Standard Title and Body. We will use the many powers of CCK to create a fictional Video Game Review Website"
- Create a new content type called "Videogame Review" (gamereview)
- The Title Should be named Game Title
- The Body should be named Review
- Add the following:
- A text field for the game publisher. Check Required (Talk about how different modules can extend CCK. Time the ending of the sentence to the start of the next field)
- A money field for the price. (Uses the Money CCK Module) Check Required
- A date field for the release date. (Uses the Money CCK Module) Input style - "j/F/Y" (The j is the day without leading zeros, F is the month spelled out, Y is the full 4 digit year) Check Required.
- A textarea for a short review summary (Actual review will be in the body) Set the Maximum length to 255. Check Required
- Integer-Radio buttons for the game's review score. Minimum – 1; Maximum – 5; Suffix - " star| stars"; Values: 1, 2, 3, 4, 5 (Mention what the pipe (|) does in the suffix) Drupal stores the prefix/suffix separately
- Text-Drop-down select for the game's official ESRB rating. Check Required
- Checkboxes for the game's genre(s) – Action, RPG, MMORPG, Adventure, Platform, FPS, Sports, Puzzle, Simulation, Party, Compilation – Remember to check "Multiple Values"
- A link to the game homepage (Uses the Link CCK Module) Set the Static Title to "More Info"
- Set up the display fields so that the teaser view has only the publisher, date and review summary
- Set the weights (Manage Fields) to the following:
- Game Homepage – -6
- Review Score - -4
- Game Publisher - -3
- Genere - -2
- Price - -1
- Release Date - -1
- Review Summary – 0
- ESRB Rating – 1
- Create a new game review
- Game Title – SuperDrupal
- Review Score – 5
- Game Publisher – The Drupal Association
- Genre – Platform
- Price - $0.00
- Release Date – 14 January 2001 (Any person familiar with Drupal should recognize this date (The release of Drupal 1.0.0))
- Game Homepage – http://drupal.org/
- Review Summary – SuperDrupal owns JoyousJoomla!
- ESRB Rating – E
- Review – Standard Lipsum (copied from lipsum.com beforehand)
- Point out how ugly and unprofessional some of the things are (# of stars, ESRB rating, More Info URL)
- Set up the display fields so that the Review Score and ESRB rating are not shown on any view (it will still be stored, but display control will not be here)
- Change the Game Homepage Label to "<Hidden>"
- Create a node template file which makes those things look better. Mention that this will be available for download.
- Explain what each thing in the code means.
- Go back to the Review page and point out how much better the review picture looks.