ZenPhoto – conditional album layouts

One of the “design features” of ZenPhoto is that all albums are derived from the main Gallery object – and so all are processed using the same script.

So if you want to treat (or present) different albums in different ways, then you have to find a way around this.I’ve done this by putting a string in the “Custom Data” album field, and changing the script to process differently.

So my formatting is different according to whether the CustomData field contains the string “customer”, and depending on that, I call a different include script.
You could put it all in-line, of course, but lots of nested code means it’s gonna get a bit messy….

Anyway, here’s a snippet to demonstrate.

[code lang="php"]getCustomData(), 'customer'))
		{
                /* normal processing */
		include ('inc-album-normal.php');
		} else {
                /* customer album processing */
		include ('inc-album-customer.php');
	}>[/code]

Of course, you can use your own tests – or use case statements.

[Update 12/3/2012]

When I first to find a solution, the only answer I could find within the package was the fairly clunky approach of assigning different albums to different themes – so you had to have a “dummy” theme – and (if I remember correctly) copy the css file across (and keep it in step) for each variant.

Since then, I’ve discovered the “multiple layouts” plugin, which ships with the package (and lives under the plugins tab). Although this seems to have sneaked into the release in December 2010 … there was nothing in the forums.

If you enable this, then go into the plugin options and select the “albums” and “images” checkboxes, then you can have separate album templates for each album behaviour you want.

You can still save out common sections into separate include, of course.

This is a better way of doing things 😀

Leave a Reply