Two Powerful Drupal Modules: CCK and Views

OK, so the Content Creation Kit is easily the most powerful module for Drupal. But only when paired with the Views module. The CCK module allows you to create custom content types. The Views module allows you to create a page that displays content that can be sorted, arranged, and displayed in almost any fashion, with some simple ajax functionality to boot.

To give an example of these two modules working in concert with each other, I will attempt to explain a recent site I built, along with talented interaction designer Parth Bhawalkar, completely in Drupal, the Stray Rescue of St. Louis website.

Building a “Custom” CMS with Drupal

For Stray Rescue, we needed a way to allow non-expert computer users to add animals available for adoption to their website. I could have said, ok, let me build you a custom application for that, write something in a month, and deliver it to them. Then attempt to “train” them on it. Well, instead of wasting my time with that, I decided to build the site in Drupal 6 with CCK and Views powering some “custom application” functionality.

For this specific mini-application, I needed a way for users to add content into specific fields for name, age, breed, type of animal, thumbnail, full image, etc. With CCK, I was able to build a custom content type that allowed administrative users to enter some basic information about each animal, which would later be important when creating a View for this content type.

Creating a View for Your New Content Type

OK, so now admin users have a place to enter in this data. Great. But what about people actually looking for a pet? How can I give them an easy-to-use interface for browsing pets and applying to adopt one of them? Well, with a combination of CCK, Views, Contemplate, and Webforms, I was able to construct a path that allowed users to browse dogs or cats, select one they wanted to adopt, and submit an adoption application with the name of the pet pre-filled in the form.

The page above is the main pet listing page, which was built using Views. You can see the live page here. The configuration page for this specific view is shown in the image below:

This page took me a while to figure out, but basically, the Fields are the pieces of data you want to display and the Filters allow you to sort out the pages/content you don’t want to display or want the user to control. In my case, I only want to display any node with a type of “pet listing” and I want the user to be able to toggle the type of animal they are looking for in the list. To do that, I added another filter for Content: Type of Animal. That means the user can change the filter on the front-end to view only dogs or only cats.

Where Does Contemplate Fit In Here?

Below is an actual pet listing page created when a pet is added. Contemplate provides a list of every piece of data available for this page and a quick and easy way to slap it into a template and override the default template with your own custom template.

This post was written to whet your appetite for Drupal and it’s amazing modules, CCK, Views, and Contemplate. If you are interested in learning more about how the Stray Rescue Drupal site is configured, I would be happy to share the knowledge I gained throughout the entire process. Drupal’s documentation is horrible, especially since there are multiple active versions and not every version has the same modules (at least not stable).

Bookmark or share this:

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Design Float
  • E-mail this story to a friend!
  • NewsVine
  • Ping.fm
  • Print this article!
  • Reddit
  • StumbleUpon
  • Technorati
  • Tumblr
  • TwitThis
  • Yahoo! Buzz