This site is archived.

Views: The Key to the Drupal Castle

Introducing Drupal

Views: The Key to the Drupal Castle

Day:  Wednesday, 25. august 2010
Time:  16:00-17:00
45 minutes (+15 minutes Q&A)



The Views module is one of the most innovative and important Contributed Drupal modules, second in usage only to Drupal core.

Views empowers site administrators to easily create customized listings of content, and has changed the way developers build their modules. In this session, we'll focus on how Views empowers site administrators to build complex listings of content without any programming knowhow.

First time views users might be intimidated by Views' complex and powerful interface, but this session will clearly present the fundamentals of its operation and provide site-builders with a mental framework for building with Views. Don't be intimidated by filters, displays, fields, or relationships (Views relationships, that is). Come learn why Views is so popular and is the key to the Drupal castle!

Come see how Views makes it easy to create:

  • Dynamic photo galleries based on a tag
  • A Map of user locations
  • A list of blog posts sorted by post date
  • Virtually any listing you can imagine!

Image credit: .


I have a more complex use

26. August 2010 - 16:03

I have a more complex use case than those exposed in the talk, maybe you can give some insight?

Let's say I have 3 CCK content types: Company, Department, Employee. My Drupal site therefore has nodes for several Companies, Departments and Employees.
Each Company has several Departments, each Department belonging to only one company. Each Department has several Employees, each Employee belonging to one Department only.
How could I make a View to display the list of Companies, and for each Company its list of Departments, and for each Department its list of Employees? Or in other words, display all the employees, but grouped by Department and the Department grouped by Company:


I am assuming the Companies have multiple CCK node reference fields to the departments, and the departments have multiple node references to the employees. The departments a single node reference towards their parent company, and the employees a single node reference towards their parent department.

I have managed to list the companies and their departments, grouped by company, but not managed to list the 3 levels at the same time.

If it's not possible to do this with Relationships and CCK Node Reference fields, maybe it's possible to do it with taxonomy? For example we could tag the departments with their parent companies' names, and the employees with their parent department names', and have the department tags be children of the company tags.

I asked this question to Ezra after the session and we agreed that I would post it here for everyone to see the solution :)
Thanks in advance, David

Thanks for your question --

7. September 2010 - 20:55

Thanks for your question -- That's quite a use case ;) !

Here are a few strategies to consider:

1) Use to display the hierarchy. This module is built to display hierarchies with Views, though the output may not be the same format that you're looking for.

2) The Views tree module, written by Larry Garfield (Crell) is designed to display hierarchies with Views formatted like a list, using a single database query. I haven't used it myself but it seems worth a look:

3) Make a view of company nodes and either in the theme layer or via Views embed, embed a list of department nodes in each company node. Use the same technique with department nodes to display employee nodes. This solution seems likely to not be performant, and you may wish to cache the output from the parent view using Views' built in caching.

4) There's a patch needing review at at for Views 3.x to allow grouping by multiple fields and provide hierarchical fields.

Using taxonomy to store the hierarchy is a great idea, but per, it's not supported by Views and has been "won't fixed".

You might find something like which uses the core Book module to store hierarchy, to be a decent solution.

As you may have found, storing hierarchy in Drupal is a bit of a challenge! I hope this helps, and feel free to continue the conversation here or in the Views issue queue.