Thank you for visiting Learn By The Drop. Since this site is no longer being updated it's important to let you know that comments are closed and contact form submissions will not be answered. Please feel free to enjoy the content that is here for as long as it is valid.
This lesson shows how to create an image gallery using CCK with ImageField, Views and ImageCache. CCK is used to create a new "image" content type that contains an upload field for images courtesy of ImageField. ImageCache is used to crop and resize the uploaded images. Views is used to display gallery page and an accompanying RSS Feed.
The premium version of this lesson is encoded at the full 1024x768 resolution as originally recorded.
How (or even if) you use RSS on your Drupal site is a decision that all site builders should consciously make. I provided an overview of the RSS features in Drupal in a previous post. Since writing that post I have extended my use of RSS in Drupal via the CCK module.
One of the things that is new to CCK in Drupal 6 is the ability to add RSS specific display settings. The settings (pictured below) allow you to indicate whether a field that has been added with CCK should be displayed in the RSS feed or not. This feature allows an increased level of customization since you can choose what to display on a field-by-field basis. Some might choose to leave it alone and display everything in the RSS feed but some types of fields (like embed codes for instance) may not render well in RSS feed readers or when imported to other sites.
I'm using this feature to add a special "RSS Only" signature to items that are in the main RSS feeds on the site. The message won't be seen when people view the posts on my site but will be seen when content is consumed via the RSS feed, including when other sites import and display the content from the RSS feed.
There are a couple of good reasons to consider adding a signature to your Drupal RSS feeds. If your post contains additional content that might not be seen via the feed you can help the reader by letting them know that this is the case. You can also link to your content licensing guidelines to inform people what constitutes proper use. The second point is important these days since importing and re-distributing RSS content has become much more popular. While some sites like Drupal Planet aggregate as a service to the community, there are other spam sites that import content while placing banner ads all around it. Adding an RSS signature to your feeds can't prevent improper use of content, but it does serve notice that you may take action if someone does use your content improperly.
Creation of the RSS signature was very easy with the CCK module.
I added a new field with a type of 'text' and a form element of 'Text Area (Multiple Rows)'
I configured the field to be required and have a 'default value' that contained the message I wanted to add to my feeds
I edited the basic 'display fields' settings and set the field to 'hidden' for both the teaser and full node
I checked the rss 'display fields' and set the field to 'default'
Now when I create a new post I see the following field in my post editing view. I leave the field as is but I could edit it on a post-by-post basis if I wanted to.
The only shortcoming that I have found with this approach is that previous posts won't have the RSS signature added unless I go back an publish them again. This is certainly a case where an RSS signature module would be of great assistance. I don't have the skills as of yet to write such a module, so until one shows up this is the method that seems to work best.
Content Construction Kit (CCK) is one the most important and at the same time most mystifying features of the Drupal platform. In this drop I'll provide a high level overview explanation of CCK and why you might want to use it on your site.
What is CCK?
CCK is a contributed module that allows you to:
Add fields to an existing Drupal content type
Create new custom content types
Drupal Content Types
It's important to understand a bit about Drupal content types. Drupal comes standard with blog, page and story content types. The main difference between these content types is the way they are organized by the system.
Blogs are associated with a particular user and will be listed at 'http://www.yoursite.com/blog' which shows all blog posts by all users. Blogs will also be listed on page that shows only posts by a particular user. The url for those pages may be something like 'http://www.yoursite.com/blogs/[username]'.
Pages will simply have a url " and not show up in any lists unless you take some sort of action to do add them to a list.
Stories are like pages except that they are automatically promoted to the front page.
The common thread across these three types of content types is that by default they contain two fields called Title and Body. But what if you want to expand a content type to add more fields? That's where CCK comes in.
CCK allows you to add one or more fields to an existing content type. There are a number of reasons why you might want to do that. You could add fields to improve your workflow. If you're publishing video you might want to add a link to the video each time you post. Adding a field that is required when you submit ensures that you won't forget to add the link. See my post Adding Fields With CCK for an example.
You could also add a field to make it easier for you to organize or theme your content later. When a piece of information is entered into the body field you can't really sort that piece of information or use it if you want to create a list using views. But once a piece of information has it's own field you have much more flexibility. Using the video publishing as an example once again you might add a field that displays the duration of a video that is linked to a post.
Creating New Content Types
If you want ultimate flexibility in customizing your content types then you can use CCK to create a whole new content type that meets your specifications. Imagine that you want to be able to add information about your favorite DVDs to your Drupal site. The title and body fields probably won't meet your needs. You might want fields that list the Director of the movie, the top stars, release date, rating, an image, a link to the trailer and more. CCK was tailor made for things like this.
How Does CCK Work?
Many people are confused about how exactly to put CCK to use on their own website. You get started by downloading the module from http://drupal.org/project/cck but you will likely have to do more. The power of CCK is in the types of fields that it allows you to add to a content type. The contributed module includes several standard fields (like text and node reference) included but many of the fields you would want to add to your content type must be downloaded and enabled separately.
Here are some additional fields that are listed on the CCK module page on Drupal.org:
Computed field: lets you add a PHP-driven "computed field" to CCK node types
There are many other fields that you could use to customize your content type. These can be found in the CCK modules section on Drupal.org. Some of the interesting fields that you might want to add are listen below.
Your new content type is basically a list of fields that are ordered a certain way. Creating a new content type and adding fields is only part of the work you'll need to do in order to make CCK work for you on your Drupal site. Each field that you add has settings that must be attended to. You may also be concerned with how the new content type is displayed when you publish a node. The Contemplate module allows you to adjust the layout and customize the appearance of content types. If the content type you have created is brand new then you will need to use the Views module to create a page, block or RSS feed for the content.
Another thing to consider when creating a new content type is the path to the nodes that you create. By default content created on your Drupal site will have a path that looks something like 'http://www.yoursite.com/node/24'. If you're submitting the DVD content type that I mentioned above you might want to the path to be something like 'http://www.yoursite.com/dvd/[movie-title]. That's why I highly recommend the PathAuto module for automatic node url creation.
These are screenshots that show what CCK features look like in the adminstration section of this site.