My Drupal Conundrum
I’ve spent a good portion of the day today trying to duplicate – in Drupal – something that I can build in about 30 minutes by directly writing source code. At this stage, I’m going to throw this out to the Internet in the hope that someone else can help me figure out what I’m missing.
Several years ago I worked on a team that took the Herrick Building Archives online. This archive is a complete history of every structure that’s ever existed at Ohio State. The central focus of the archive is a building record – like this record for Ives Hall, former home of the Knowlton School of Architecture (where I work).
A building record is comprised of two basic pieces of content: the core building record, and zero or more addenda that were written each time the building was renovated.
To accomplish this in Drupal, I used CCK to create two content types: Building (for the core record) and Addendum (for each addendum. The Addendum content type has a node reference field back to its parent Building, which establishes the data relationship. When I coded this by hand, the addenda table had a foreign key back to the building table ID field.
The display page on the original site, then, essentially followed this structure:
- Get Building ID from querystring
- Look up core building record (date, text, etc) from building table; print that information
- Look up all records from the addenda table which reference this building record (i.e. “SELECT * FROM tbladdenda WHERE BuildingID = 7”)
- Loop through that recordset and print out the addenda text for each record
Easy, to the point of trivial. But how to do this in Drupal?
My first thought was to build a View, and take advantage of Tokens. Build a View that looks up all addenda which reference the current building ID. The problem I ran into, though (I think) is that the URL I’m working from is something like
http://mysite/building/Ives-Hall (building name)
http://mysite/building/7 (building ID)
This presented a problem when I tried to specify the argument in the view, because the preview only worked when I specified the building ID – not the building name.
My next thought was to make the entire page a view, using a Page display to show the core building record and then using an attachment display to look up the affiliated addendum records. That hasn’t worked either, perhaps for the same reason. I suppose this might be able to be fixed if I could just accept using an unfriendly URL, but I get the feeling that I’m missing something simple.
So – for those of you who read this blog – what am I missing?