Poplar ProductivityWare Articles:
Custom Content Types in Drupal
A Video Tutorial
by Jennifer Hodgdon
On April 26, 2008, I gave a presentation at LinuxFest Northwest on how to create custom content types in the Drupal web-site content management system. The talk was recorded on video, and is available for viewing on-line:
- Video - this page says it is "Part 1 of 2", but it actually has the entire talk
I also gave the same (or very similar) talk at Drupal Camp Vancouver, on May 9, 2008. If you'd like me to come give this talk to you, please contact Poplar ProductivityWare.
Unfortunately, it is very difficult to read the overhead screen in the video. So, below you can find the information from the Background Information, Outline, and Planning sections of the talk, as well as screen shots from the rest of the talk. You may want to refer to these as you watch and listen to the talk.
There is also an "extra credit" section below, which didn't make it into the video.
If you are unfamiliar with Drupal, you may also want to check out the Background Information before viewing the video.
Background Information
- For basic Drupal information, including terminology, installing, basic site building, and links to a lot of other information, read my Drupal Cheat Sheet article, elsewhere on this site.
- Drupal versions and modules used for this talk - get these at drupal.org:
- Drupal 5.7 with built-in "PushButton" theme
- Content Construction Kit (CCK), along with its separate sub-modules ImageField, and Date
- Views, along with its separate sub-module Calendar
- Slides and/or videos of other Drupal talks at LinuxFest Northwest 2008 can be found on the LinuxFest Northwest web site, and on the Drupal Camp Vancouver presenters' notes page for that event.
Outline
- Planning data/content types
- Creating data/content types - Content Construction Kit
- Creating vocabularies/categories - Taxonomy
- Data entry
- Displaying data/content types - Views and Blocks
- Menus [note: there wasn't time to cover this in the talk]
Planning
Example: Web site for an organization that offers art classes, taught by several instructors.
Types of information/content:
- Instructor: name, bio, photo, subject areas (drawing, painting, etc.)
- Course: name, description, subject area (drawing, painting, etc.), age level (elementary, middle, high school, adult)
- Scheduled Class: course (link/reference), start date, end date, start time, end time, cost, instructor (link/reference)
Information Displays (Views):
- List of upcoming scheduled classes - sort by start date
- List of courses - allow viewer to filter by subject area and age level
- List of instructors
- Scheduled Class detail - links to instructor and course description
- Instructor detail - show list of upcoming classes this person is teaching, and what they have taught in the past
- Course detail - show when this course is scheduled
Screen Shots for Creating Content Types
(Click on a link or small image to see the screen shot.)
Screen Shots for Taxonomy
(Click on a link or small image to see the screen shot.)
Screen Shots for Data Entry
(Click on a link or small image to see the screen shot.)
Screen Shots for Views
(Click on a link or small image to see the screen shot.)
Adding Block Views to a Page
This didn't make it into the video - it's the "extra credit" section on how to make views show up on page.
Here are the steps for making the "Upcoming Classes" section appear on the Individual Instructor page (see screen shot of Individual Instructor page above):
- Whenever you enter content for an Instructor, be sure to give it a path (URL) of instructor/something. Screen shot:
- Define the view. This will be a "block" view, rather than the "page" view demonstrated previously in the talk, but the fields section and filters work the same as the previous view. It will need an "Arguments" section, though, which is new -- what this will do is make it so that only the classes being taught by the particular instructor we are looking at are shown. We use some special "Argument Handling Code," which finds the instructor's internal Drupal ID number, and tells the view that this is the instructor we are interested in. See the Contextual View Blocks Snippet on drupal.org for more information. Screen shot:
- Once that view is saved, it will appear in the Blocks management screen. So go to Administer / Site Building / Blocks. Find the "Upcoming Classes for Instructor" block in the list of blocks, assign it to the "Content" region of the page (which will display it below the body and fields of that piece of content in most themes), and click "Save Blocks". Screen shot:
- Finally, we need to make it so this block only appears on Instructor pages, not every page of the site. To do that, click Configure next to the "Upcoming Classes for Instructor" block, and tell Drupal to display this block only on pages with URLs like "instructor/whatever". Screen shot:
Poplar ProductivityWare: your Seattle-area source for web databases, web programming, Palm OS applications, and analytical/modeling software
Home | Web Programming | Custom Software | Articles | Downloads | Testimonials | Values | Contact UsPoplar ProductivityWare® is a trademark registered in the U.S. Patent and Trademark Office
Copyright (C) 2003-2008 Poplar ProductivityWare LLC