Adventures in Photo Galleries

Submitted by Kevin on

All blog entries reflect the opinions of the author and have not been expressly endorsed by the Ivan Allen College of Liberal Arts or the Georgia Institute of Technology.

One of the things I've always dreaded about putting together a website these days is the request to have a photo gallery in it.  Yes, you can add modules to Drupal to give it something akin to photo gallery capabilities, but I've never tested anything that really worked well or offered the features of a stand-alone system.  So, with six school websites on my plate for redevelopment over the course of this year and next, I decided it was time to figure out a way to really integrate a stand-alone photo gallery system in with Drupal and the Georgia Tech theme in a neat and tidy way.

My first challenge was selecting a photo gallery system.  I've always liked the Gallery system, but unfortunately that project went on hiatus last year and hasn't shown any signs yet of coming back to life.  So, I did some research and found some mentions of ZenPhoto.  Well, it turns out that ZenPhoto is actually a fork of the Gallery system (Gallery 2, I think), so that worked out perfectly for me:  a good system that's being supported and has the features and back-end structures of Gallery.

I set up a copy of ZenPhoto and figured out its interface very quickly.  It's base theme is very clean and simple, but gives you access to all of the system's features.  I set up some albums for the website I was working on and easily loaded them up with pictures, as ZenPhoto can automatically detect image files that you copy into the album folders on the web server's filesystem, so there's no need to upload tons of files through a web interface during an initial migration.

The big question was how to integrate the ZenPhoto system with my main Drupal website.  I knew there used to be a Gallery integration module for Drupal, but I never liked the way it worked, and that wasn't really the kind of integration I wanted.  My goal was to theme ZenPhoto to look like it was an extension of the Drupal site, but without it actually running under Drupal, so that you're not bootstrapping Drupal just to render one of ZenPhoto's pages.  I also didn't want to put ZenPhoto into an IFRAME either -- that's just too last-century for my tastes.

So, I sat down and worked up a Georgia Tech theme for ZenPhoto, integrating code from the stand-alone Georgia Tech theme that Institute Communications (IC) has released (code that, BTW, I have been using in some of my stand-alone PHP applications and had updated myself to reflect the most recent changes in the Georgia Tech theme -- I'm not sure that the code on IC's website has all of those updates yet.)  Unfortunately, ZenPhoto doesn't have a single template file -- it has separate templates for front page, album page, image page, etc., so I had to do a little more work than I would have liked.  Even so, I was able to boil it down to cut-and-pasting the necessary header lines into each template along with a call to render the masthead and another call to render the footer, with the code for both calls in an include file.  The icing on the cake is that I added a few more routines to suck the main menu out of my Drupal site's database along with the social media links menu, so that I could render them on all of the ZenPhoto pages, maintaining consistent menu navigation between the main Drupal site and the ZenPhoto site.  It's actually a lot easier to do this than you might think, but you do need a good understanding of both Drupal 7 and the way the internal structures of the Georgia Tech Theme work.

The net result is that for about half-a-day's work, I have ZenPhoto themed to look almost exactly like an extension of my main Drupal site.  I am still missing the custom links in the superfooter, but those could be added in as well if I ever felt like spending a couple more hours on the ZenPhoto theme.  For now, I don't consider them important enough to spend the time on them right now.

If anyone else would like a copy of my Georgia Tech ZenPhoto Theme, I've posted a copy to my Downloads page (available on-campus or via the campus VPN only).  I did take the time to add some configuration options so that you can configure it for your site without having to modify any of the PHP code, but otherwise it hasn't been polished up at all, and of course it's use-at-your-own-risk and not warranted in any way, shape or form.