Updating your zenphoto theme for zenphoto 1.1
I use zenphoto as the backend to my photos section with a custom theme to hook into my site’s navigation and such. I chose zenphoto for my website a year ago based on it’s main strength: simplicity. It does much less than the competition, but it does what I need it to do—for the most part. It’s a fantastic bare-bones mysql/php photo gallery option.
Since then, though, I (along with many others) have been slightly disappointed by the lack of development in the promising project, without having the time or energy to pitch in myself. Such is life. But now the wait is over: Zenphoto 1.1 is out.
Zenphoto 1.1, I believe, does a good job balancing this tradition of simplicity with some popular new features. Highlights include (there are many) tagging, subalbums, chronological archives, RSS feeds, EXIF support, Google Maps, search, and preliminary video support. Exciting stuff.
As I maintain my own theme, though, some of these new features of course require me to update my theme. Below is my rough guide to editing your theme to take maximum advantage of zenphoto 1.1.
First things first
Between the core components moving from /zen to /zp-core and the addition of subalbums, your old .htaccess will no longer be valid. Make sure to copy over the new .htaccess (in the zenphoto 1.1 zip file, though probably invisible in your filesystem) with necessary updates for your setup, or else none of your images will show up. Ha!
Search and Archives
The first thing you’ll notice if you check out the default theme is the search and archive pages… the easy way to implement these, I think, is to copy over the search.php and archives.php pages and then make the necessary organizational changes. This is of course easier said than done, but everyone’s custom theme exists for different reasons.
To implement search, you first have to add the search box to the index page:
if (getOption('Allow_search')) { printSearchForm(); }
The default theme has this right above the gallery title, but I put it at the bottom of my main div.
Subalbums
Subalbums are an exciting new feature for organization buffs, but it does require some quick changes. First of all, the subalbum-path breadcrumb must be added to album.php and image.php, right before the current album/image name. Use the three parameters to change the delimiters.
printParentBreadcrumb($before,$between,$after);
By default, subalbums are listed at the top of an album’s page, so we have a new while(next_album()) loop there. The default theme’s additional loop1 is:
<?php while (next_album()): ?>
<a href="<?php echo getAlbumLinkURL();?>">
<?php printAlbumThumbImage(getAlbumTitle()); ?></a>
<a href="<?php echo getAlbumLinkURL();?>">
<?php printAlbumTitle(); ?></a>
<?php printAlbumDate(""); ?>
<?php printAlbumDesc(); ?>
<?php endwhile; ?>
Tag Support
Simply add this line to the bottom of album.php and image.php:
printTags(true, 'Tags: ');
RSS Support
To enable RSS support, simply put the printRSSHeaderLink() in your headers. I used these three lines:
printRSSHeaderLink('Gallery','RSS title');
printRSSHeaderLink('Album','RSS title');
printRSSHeaderLink('Image','RSS title');
Now your RSS feeds are added as links in your header, and will be recognized automagically by a smart browser. You can also add an explicit link:
printRSSLink('Gallery','','RSS', ' | ');
Maps and EXIF
While I haven’t implemented these myself in my theme,2 these look fairly simple to add to a theme. The key PHP code to include are:
if (getImageEXIFData()) {
printImageMetadata('', false);
}
and
printImageMap();
There’s more
There’s of course more advanced stuff that might be of interest to other theme designers. The place to start is probably normalizeColumns().
Feel free to check out my final product, the updated photos section.
-
listed here as just the php logic, without the organizational html ↩
-
I use slimbox, the mootools-based lightbox clone and, thus, never use the image page or comments. What I have done, however, is just put some of that EXIF data in the title tag to be displayed by slimbox by manipulating the value of
getImageEXIFData()in thewhile(next_image())loop. ↩
No related posts.
Tags: code, PHP, theme, zenphoto
If you enjoyed this post, make sure you subscribe to my RSS feed (optionally with tweets from my Twitter)!
November 4th, 2007 at 6:55 pm
I am proud of you, and that is okay with me.
December 21st, 2007 at 9:59 am
[…] Our user Mitcho wrote a nice roundup how to do that: updating your zenphoto theme for zenphoto 1.1 […]