My recent introduction to CCK, Contemplate, Views and Node Import modules for Drupal.

January 10, 2008

In a previous post, “A Possible Approach to Importing Static Content Into Drupal”, I talked about trying to find a quick and dirty way to populate Drupal, in that case migrating existing static Web pages. What I came up with then wasn’t a complete solution, but I thought it might be a promising start.

Along similar lines, I recently started working on a site in which I created a custom content type with CCK and needed to quickly create multiple objects of that type using data from a client’s spreadsheet. After cleaning up the data in the spreadsheet (no matter how careful people think they are, they always enter dirty data in spreadsheets), I tried out a Drupal module that was new to me, Node Import.

As I’ve come to expect from Drupal modules, Node Import is quite mature, easy to use, and integrates well with CCK content types and taxonomies, which I also am using quite heavily. Using Node Import, you can create new nodes by processing a tab or comma separated text file into Drupal, complete with preview and error reporting.

Having lurked about the Drupal community for some time now, I was surprised that I hadn’t heard of this module before. Its very well implemented, and I can imagine many different uses for it.

So, does this change my thinking about how to import static content? Not quite yet, although I did see an interesting thread in the Drupal forums about using Node Import along with a product called Screen-Scraper which promises to “extract information from Web sites”. I haven’t tried this software yet, but the next time I need to migrate a static site to Drupal, I’ll try to find the time to test this out and update the blog with my thoughts on it.

Incidentally, when I tried CCK initially, I assumed that I would very quickly reach a point where that approach would not provide the power and flexibility I needed to create my custom content type, and I would end up coding a new module for the functionality. It just didn’t seem possible that through a graphical interface, I could create anything more than the most basic new object type.

But Drupal and its module authors came through again, and along with the Contemplate and Views modules, I quickly created exactly a new content type with all the bells and whistles I needed, writing a small fraction of the code I would have needed to code a new module from scratch. For the uninitiated, here are some links:

So, CCK allows you to create new content (node) types in Drupal through the administrative interface. Contemplate then allows you to control how those nodes are displayed. The Views module is basically a sophisticated query builder for displaying many nodes in a list or table, for example.

And you can extend CCK with modules that provide new field types, complete with the appropriate validations. It all works extremely well and is integrated into Drupal, and while I’m sure there are times when it is still more appropriate to code a new module from scratch, using CCK seems to be becoming the preferred way of creating new node types.

Finally, CCK and Views can be a little overwhelming at first, and this screencast (30 minutes long) gives a great introduction to these modules.

Comments »

No comments yet.

Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.