A Tabbed Overview Page Using Tabs, CCK Fieldgroups, and Viewfield

Submitted by Barrett on Sun, 09/26/2010 - 15:29
A Tabbed Overview Page Using Tabs, CCK Fieldgroups, and Viewfield

I've been working on a travel site for a friend, highlighting Costa Rica as a tourist destination. To express the things there are to see and do in Costa Rica, I've created four content types:

  • Regions
    - areas of the country
  • Destinations
    - places to go within Regions
  • Tours
    - things you can do at a Destination
  • Hotels
    - places to stay

Hotels and Destinations are linked to Regions by means of a Node Reference field and Tours link to Destinations in the same manner.

What I wanted to do was create a Region overview page that would show the body of the Region as well as all the Destinations and Hotels in the Region. Setting up views for the Hotels and the Destinations and attaching them using Node Content displays was easy. However, since there are a variable number of Destinations and Hotels that might be in a Region, finding a way to easily display them was giving me fits. I decided what I really needed was a tabbed interface so that a user could easily switch back and forth between displaying Destinations or Hotels.

A few quick searches netted me two promising modules: Tabs and CCK Fieldgroup Tabs. The former is a helper module adding in the JQuery UI Tabs plugin. The latter makes it possible to set CCK fieldgroups to display as tabs.

All looked well...then reality set it. The CCK UI would not allow me to move my attached views into the fieldgroups I created. I figured I was going to have to dig into code and start tweaking preprocessing functions to try to get the content of my views into the fieldgroups. Fortunately for me, before going down that path, I threw out the question in the Drupal-Support IRC channel.

Almost immediately, another user came back with the suggestion of Viewfield. This wonderful little module allows you to put the content of a view into a CCK field. Once I had it installed and configured, everything just came together. With no fuss (and no code) I had a clean tabbed interface for showing views content on my Regions.

Barrett Sun, 09/26/2010 - 15:29

Tags