CCK And Views Drops

These are drops that provide information about CCK and/or Views.

Creating Custom Lists Using Nodequeue

The Nodequeue module is an incredibly useful module that allows you select individual nodes and place them in a list in whatever order you like. This lesson shows you how to create a new nodequeue, add nodes to the queue, arrange the queue and then add the queue to a view.

Note: Click the 'full screen' icon (to the left of the volume control) in order to watch online at full 1280x720 resolution.Note: Click the 'full screen' icon (to the left of the volume control) in order to watch online at full 1280x720 resolution.

Bookmark and Share Bookmark or Share Post

Image Gallery Enhancements

This lesson shows you how to enhance the image gallery created in the previous lesson using Thickbox, Media RSS and Views Slideshow.

The premium version of this lesson is encoded at the full 1024x768 resolution as originally recorded.

Bookmark and Share Bookmark or Share Post

Create An Image Gallery With CCK, Views And ImageCache

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.

 

Bookmark and Share Bookmark or Share Post

The Power Of Drupal Views

 When people ask me why I would ever use Drupal to build a website instead of other platforms like WordPress or Movable Type I typically have one answer, "CCK and Views." That could be interpreted as two answers but since the modules go hand in hand I'll call it one. I've written about the basics of CCK before so I recommend that you check out that post if you're interested in understanding CCK better. This post is about the Views module.

Views is a module that offers Drupal site developers (you I presume)  great flexibility of choices for displaying content. Views provides this flexibility by offering up a graphical user interface (pictured below) that allows you to query the Drupal database for content and choose the format of the content display without having to write SQL queries. I've written plenty of SQL queries in the past for business purposes and if I never write another one I won't be disappointed. If you want a much closer look at the interface I'm speaking of feel free to check out one of my videos that shows you how to do something practical with views.

Views Interface

Views Interface (Drupal 6)

Three Basic Types of Views

There are three basic types of views available in the base module. You can display content as a page, block, or RSS feed. When I say "content" I mean entire Drupal nodes or individual fields. For example, the page at http://learnbythedrop.com/cckandviews is a "view" that lists x number of nodes. When you list the node you get the Title + Body, plus links to comments and any other fields that would display when you are viewing a node. If you choose to display fields instead of nodes, then you can pick and choose individual fields from your nodes to display. For example,. the page at http://learnbythedrop.com/archives displays the Title (linked to the node), (Number of) Views, (Number of) Comments and (Number of) Votes fields.

The one thing that the views mentioned in this paragraph have in common is the fact that they are "page" views. Page views differ from other views because you assign a path (like http://learnbythedrop.com/archives) that displays the view as a page on your site. You can also create your list in a "block" view. When you choose block the content that you add to the view will be available on the block page (at admin/build/block) for configuration and placement just like any other block on the site.

You should put a little bit of thought in to what types of content you display in a block vs. a page. Blocks work well with lists of titles linked to nodes (see the "Recent Drops" and "Comments" blocks in the right sidebar), whereas a page might work best with full nodes or a collection of fields. Lucky for you that the views module has a very handy "live preview" feature that allows you view the results of your query while building your view.

The third type of standard view is the RSS feed view. This view outputs lists of nodes as an RSS feed that people can subscribe to in a feed reader such as Google Reader. If you have set up a page view that has the same content as the RSS feed you have the option to associate the RSS feed with that page and a small orange RSS Icon will appear on the page. See the bottom of the page at http://learnbythedrop.com/gallery for an example of how this looks.
 

Style Options

Drupal views also have several standard "style" options which differ depending on the type of view you choose. RSS, for example, is really a style option for your view. But if you choose to set up a page or a block view you have different options as to how the final display will appear. Some examples of style options are unformatted, list, grid and table. If you're creating a page full of nodes then you'll likely choose "unformatted" as your style. But if you're choosing a page with individual fields (like http://learnbythedrop.com/archives) then a "table" style might work best. For blocks that have lists of titles linked to nodes I typically choose the "list" style. Once again, the live preview option is your friend when making these types of decisions.

The "grid" style is an interesting choice if you're displaying just a couple of fields and want to repeat the content across and down the page. I've implemented this style on my view at http://iheartmets.com/metstweets, which shows a grid of recent tweets about the New York Mets.

Bookmark and Share Bookmark or Share Post

Using Views To Create A Block

This lesson shows how to use the Views module to create a block that contains a list of node titles that link to their respective nodes.

Bookmark and Share Bookmark or Share Post

Creating An RSS Feed Using Views

This tutorial shows how to create an RSS feed from an existing view. See Creating A Page View From A Taxonomy to see how I created the initial page view.

Bookmark and Share Bookmark or Share Post

Adding RSS Only Fields

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.

Bookmark and Share Bookmark or Share Post

CCK Module Basics

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:

  1. Add fields to an existing Drupal content type
  2. 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.

Adding Fields

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
  • Date: creates an ISO or unix timestamp date field
  • Email: validated email field
  • Image field: an image field
  • Link: a URL field

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.

What Next?

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.

CCK Screenshots

These are screenshots that show what CCK features look like in the adminstration section of this site.

CCK FieldsCCK Field Display SettingsCCK Node Submission Fields

Bookmark and Share Bookmark or Share Post

Creating A Page View From A Taxonomy

This video shows the user how to use the views module in Drupal 6 to create a page that list nodes with a certain taxonomy term. For the screencast I created a view that lists all of the nodes tagged with cck or views at http://www.learnbythedrop.com/cckandviews.

Bookmark and Share Bookmark or Share Post

Adding Fields With CCK

This video shows how to add extra fields to existing content types (such as blog posts) using the Content Construction Kit (CCK) module in Drupal 6.

Bookmark and Share Bookmark or Share Post
Syndicate content