Drupal Articles » Creating a CCK and Views powered Drupal site


By David - Posted on 03 August 2008

The goal of this guide is to take you step by step through the full process of using Drupal's CCK and Views modules (as well as a number of other supporting modules) to create customized content types (e.g. news posts, articles, etc), as well as "listing" pages and blocks to display teasers of your content, and then theming everything to look exactly as you intend. This is a "mega guide" that is intended to take you step by step from a beginner level through every step to learn the majority of skills, concepts, and modules you need to make a relatively advanced Drupal site. It is not "all inclusive" by any means, but should be a valuable learning tool.

Please do not be alarmed at the length of this guide -- its length is only due to very thoroughly described steps to make this guide as beginner-friendly as possible. Each step is numbered so you can more easily keep track of your place in the guide. Although I have over 4 years of experience with Drupal, I try to put myself in beginner's shoes and not skim over details or assume that you already know things about the code or how Drupal works.

For the purpose of this lesson, a new Content Type called "Article" will be created, and a number of custom fields will be added to it. You can, however, apply this lesson to any other Content Type you wish to create or have already created. For full control, specific fields will be set up ahead of time for the Content Type using CCK, so that certain specific fields will be displayed in the teaser view but not on the full page view of the Article content, and certain fields will show only on the full Article pages but not in the teaser views of the content.

After completing this lesson, you will have built up skills working with CCK, Views, theming both Nodes (individual pieces of content) as well as Views (custom listings pages and blocks of your content), and knowledge of Pathauto and Custom Breadcrumbs. You will also gain experience working with images in Drupal using Imagefield and Imagecache (in this lesson you will learn to add images to your CCK types, and control exactly how and where those images show up, such as adding a thumbnail image in the teaser with the full size image on the article's full page).

This guide is still in the process of being written. Though not yet complete, it is still a very valuable learning resource. Currently support for Images is being added to the guide.

Tips on using this guide

  • Buttons, links, menus, etc which you are to click on are written within "Quotes".
  • The names of options/settings, when referred to, are shown in Italics.
  • Options you are to select or text/code you are to enter into setting/configuration fields or your template files are highlighted. When you see highlighted text, you should copy/paste it into the specified settings field or template file on your site.
  • When the guide calls for you to navigate to a certain administration page of your Drupal site, the path is shown in this format: Administer > Site building > Blocks and the URL is also provided (admin/build/block).
  • Occasionally, when there are alternative techniques or other guidance, a Note: will be included.

Requirements

  • This guide has currently been written and tested for Drupal 6. Many of the concepts apply to the older Drupal 5 versions of the modules used in the guide, but there are various differences (especially with Views 2).
  • The examples in the guide use the Garland theme, since all Drupal users have it. You can apply the steps in this guide to any theme you wish though.

I would steer people away from Contemplate. It does a couple of things:
1) you are typing PHP into a browser. If you screw up the PHP, bad things will happen
2) PHP is being stored in the DB. It can't be versioned, approved, or done anything else with in normal code processes.

I realize that many people find Contemplate an easy crutch to do theming ... but in reality, they really really really do need to learn the theming learning if they want this level of customization.

David's picture

Hi Boris -

Yes, since I first began the article I've also decided to steer people away from Contemplate (retaining it, if at all, only for reference if needed). I will actually remove it from the list of modules here on the first page. When you get to the Node Theming portion, you'll see that I've pointed people now to the actual theming code for the fields, showing them the most common theming code snippets and explaining how simple it is to use and reuse them; I've tried now to dissuade them from using Contemplate (the first draft of the page focused on Contemplate, but I've moved that completely off to a separate optional page that will just explain Contemplate's possible uses, that it's preferable just for reference, outline the reasons why it's NOT good to use it, and provide tips such as if they still choose to use it, to still save its output in real files and not the database). Feel free to comment on that page with details I've missed. One thing that would be extremely helpful is if on the Node Theming page you could assist in any way with additional tips on the best/most understandable way to make sense of the output of something like print_r or other methods (as in, are there any good "rules of thumb" on how best to get at the data you're after and get that into your theme, security concerns, etc).

Thanks for your feedback. I'll look forward to as many ideas and thoughts as you'd like to share.

- David

I've found Contemplate useful for theming the pages by using "template-files" feature. Creating the 3 files, 1 for normal nodes, 1 for teaser and 1 for RSS allows a great amount of customisation. No PHP is stored in the database.

When I think about it, all it really does is split the templates into 3 possible templates for each section. I especially like the teaser and full node separation.

I administer (sort of) a Drupal 6 site for a nonprofit organization. We need to design a section of our site where members are allowed to post their own pages. I was going to use Contemplate to create templates for them to choose from - for example, one with a photo gallery down the right side, another with the photo gallery at the bottom, and perhaps a third with a place for them to upload one image. I found your documentation in the process of trying to learn about how to do that, and it's giving me pause - is this not the correct module for me to use? Do you have other suggestions?

This is one of the best tutorials about Drupal that I saw, thx a lot David!

Yeah it's one of the best tutorials i ever saw !

Thanks for this wonderful tutorial. After going through it, found it a lot easier to update my site

Simply, admirable what you have done here. It is fabulous to see you verbalize from the heart and your clarity on this significant subject can be easily seen. Fantastic post and will look forward to your incoming update.

Dislikes having many content types, instead of having one for each item, why not just boost the node to do more. I'd like to see more of that, maybe include dropdown menu in each node to insert(what ever extra you need)
Viewing a long content type list is hard on the eyes.

After finding this post I find that I no longer break out in cold sweats just thinking about "Views"

I played with "Contemplate" and quickly saw it's detracting points.

I have all these great ideas for a new website and I know I need "Views" to do it but I was supremely frustrated trying to make it work.
(Everyone seems to say, "oh, once you get the hang of it you'll just love the power!" yeah, well, I don't have time to "get the hang of it" I needed someone to just tell me how this module works/thinks and getting it going "yesterday".

aaaaaaaaaaahhhhhhhhh!

thanks!

Great tutorial on using CCK with Views.
I've been using drupal a while now, and though I like writing my own modules to achieve certain things such as shopping carts, additional administrative features, etc
And then I will theme them using my css code along side custom template pages for the various nodes.

After reading this, and using CCK to create my forms along with Views, instead of coding it as a block module etc, it makes my development a lot faster.
Again, great article.

Keep up the good work.

I'm involved in using CCK with Views for a couple of months, that's nothing. This help is appreciated! Thank you!

Thanks a lot for this great tutorial. After going through it, I have found it much easier to update my site.

Ultimate note.......You described things very clearly
Thank You.