Class 3-4
No class next Thursday - see you Saturday at 9 am, May 15th!
Views of Custom Data
Overview of today's task
We're going to create some custom tables for a Photography school.
Last week we created some new Content Types and some new Taxonomy so that we could display a table called Upcoming Classes. The finished table, if you were to handcode it in HTML, might look like the table below. But you want users to be able to search on your data and display only the data they're interested in. You also want to have them search on instructors, and classes, without entering the data in two different places.
What we want to see in our drupal site - the Course links go to a description of the course, the instructor links go to more detail about the instructor:
Upcoming Classes
| Date / Time | Course | Location | Instructor |
|---|---|---|---|
| 6/10/2008 4 pm | Photographing Water Views | BayView Cafe | Anne Avery |
| 6/24/2008 10 am | Digital Darkroom | Haggard Hall 155 | Robin Smith |
| 7/4/2008 8 pm | TimeLapse Photography: Fireworks | BayView Cafe | Brian Bellevue |
Views
Views pulls together your custom content and displays it - as a table or list of nodes; in a block or page.
From drupal.org:
You need Views if:
- You like the default front page view, but you find you want to sort it differently.
- You like the default taxonomy/term view, but you find you want to sort it differently; for example, alphabetically.
- You use /tracker, but you want to restrict it to posts of a certain type.
- You like the idea of the 'article' module, but it doesn't display articles the way you like.
- You want a way to display a block with the 5 most recent posts of some particular type.
- You want to provide 'unread forum posts'.
- You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of "Month, YYYY (X)" where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month.
And then my favorite - you want to display the data in a sortable table (like a spreadsheet).
Resources
Views Documentation on Drupal.org
Here are some modules that go along with Views that you might find handy (you can look these up on drupal.org)
- Views Calc - if you need simple calculations in your fields instead of user input
- Views Embed Form - if you need to embed a form in your view - say a submit button for a shopping cart
- Draggable Views / Views Accordion - these are both ways to display styles and functionality to your views
- Views Calendar - if you want to display your dates in calendar formats
Demo
See step by step instructions for Views
