Web Developer Class: Drupal CCK: I Cee You
One module that truly does complete Drupal is "Content Construction Kit" or CCK. So much so that it has been included in Drupal 7 core (now in alpha release with beta close behind).
No doubt there have been times when you needed a simple database on your site to push and pull information for creation of a membership directory or events page, for example. You have likely created these mini applications using a combination of HTML forms, ASP or PHP, and SQL or MySQL. The CCK module makes this easy to accomplish. In fact, it puts this capability into the hands of those who know little or nothing about scripting languages or SQL statements. That being said, the developer-friendly Drupal makes all of the code readily available to a more advanced developer for further extensibility.
Case StudyOn their new Drupal website, Overseas Press Club of America wanted a mechanism for entering and displaying information about the many awards that the prestigious media organization gives out each year.
This was easily achieved by creating a new content type with a few custom database fields, created through CCK.
Creation of the HTML data entry form and injection of that data into the database table is performed by CCK and Drupal. You simply select the type of form controls from the Manage Fields tab of your content type edit form (shown below).
For this example, the resulting custom fields list looks like this, on the content type edit form (shown below):
Once the custom database table fields have been created, you can manipulate them in various ways: through other Drupal modules (such as Views), using the Drupal user interface; or through direct code manipulation, such as in template files.
One of the easiest ways to manipulate these fields is through the options of the Display Fields tab (shown below).
These basic controls let you configure if/how the field data is displayed in a teaser and on a full page, and the settings need not be the same for both.
For example: In the case of date fields, you can configure the control to show a date "as time ago" (the Twitter format); as a short, medium, long, or custom date format; or hide the date entirely. With the image type, you can select a custom pre-set image format (describing height, width, cropping, etc.), if you have a companion image module installed to handle the image settings. One use of this option would be to specify a pre-set for a thumbnail in the teaser and a different format for the image in the content's body.
For more advanced manipulation of the field data, you will use other modules, especially Views. [Views will be covered in the next article. Stay tuned!]
These custom fields can be used to display data, sort data, filter data, and invoke the actions of other code. These are the elements that make up your SQL query statement in Views, which Drupal is nice enough to write for you (see screenshot below). No need to touch your database file or to write a string of code.
Through a sneak peek of the Views module in action, you can see how these fields (preceded by the word "Content:") can be used:
Your content creators will be oblivious to all of your thoughtful work. Their view of the CCK fields will look like this, when they create content:
And, your website audience's view of the finished product will look like this:
Notice that in this application of CCK (and Views), the user can choose the data that they want to see, using the form fields.
SummaryThe beauty of CCK is that it gives non-programmers a tool to extend functionality of their website in ways that they might not have been able to do before. And, for the experienced developers, it offers all of the database functionality through a GUI interface, backed by great power and flexibility.
Will the CCK module be love at first site? I believe that it will, and it is worth the commitment. Next time, learn about Views, part of the dynamic triumvirate!
Tyme is a freelance writer and multimedia specialist of many years. She likes walks in the park, cotton candy, and baby ducks. To learn more: http://www.MultimediaByTyme.com/.
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...