I am attempting to modify a clone of the Zenpage theme to support alternate layouts, in this case an alternate to image.php. After reading the docs and the manpage with the support functions, I still don't understand how to associate a given image with an alternate layout. Essentially, what I don't get is, for:
image_<custid>.php
...what is <custid> associated with, and where's the code that evaluates it?
In this case, I want to be able to extend the printImageDesc functionality of image.php in various ways, for a subset of the images in a given album, based on things like their: filename, presence or absence of a given metadata item, perhaps check for an external alternate content file. Then, do things like: leave out the metadata description, possibly show the custom data, or call a codeblock that loads some external content.
Clearly I could do all this by hacking the image.php file, but I'd rather use the built-in mechanism if this is the type of thing it's for. (I'm trying to avoid altering the original theme wherever possible.)
Only found two other forum entries on this subject, neither of which was relevant. An example snippet would be very helpful.
thx.
Comments
In that case, you make the alternate script for your image. The name of the script must start with "image". Then on your images tab you will have the option to select this script to be used when rendering the image page for that image.
http://www.zenphoto.org/news/multiple_layouts
Our recenlt server migration resulted in some still unsolved encoding issues in case you wonder about some weird chars in the text.
Re: metadata
Since the image metadata problem triggered the need for a custom image.php file, I thought I'd include what I discovered while trying to modify the original image file. This is no big deal, but I figured this might be useful to anyone dealing with images containing lots of metadata...
Since Zenp always overwrites the user-supplied 'Title' and 'Description' fields on the Images properties page (if and only if there is metadata in the image file that it deems appropriate):
1. It appears that Zenp updates the Description field immediately on loading the properties form page (or perhaps if it notices the date has changed on the image file?), rather than waiting for the user to run the refresh metadata. I wouldn't have even noticed it had changed if I wasn't looking for it.
However, it doesn't appear to treat the Title field the same way, since in my case, I changed both fields in the image file, but only the Description field changed on the input field. Then, when I actually ran the metadata refresh, the Title field was updated as well.
If this is considered a bug, I would suggest not auto-updating the Title or Description, since the user can always do that if they want to. Ideally, I think the user-input to those fields should be protected even from being updated by metadata refresh, since that's more consistent with the way similar fields are treated elsewhere in Zenp, but I don't consider it a major problem either way.
2. I wanted to know if I left the title field in the metadata of the image file blank, would it leave my custom Zenp Title property field alone. So I edited the image metadata such that the IPTC field which was being used by Zenp to set the Title was now empty.
Instead, Zenp switched to a "backup title field" (also part of the IPTC data) and stuck that in as the Title. Not an unreasonable thing to do, just unexpected.
Here's the .xmp file for the .JPG in question (lenin.jpg):
`
<?xml version="1.0" encoding="UTF-8"?>
format
portrait;male;Roles
&
Occupations;Personality;Premiers;Dictators;Communism;Russian;Eur
568634
ARCHIVE
FILE
NO:
G1905/066
(G1889/063);KEY
P/LENIN/V
I
Keystone
Vladimir Lenin speaking in Moscow (1917).
`
The field <dc:description> is apparently preferred by Zenp as the source of it's Description property. Originally, the field <dc:title> was being used as the source of the Title property by Zenp. However, after I emptied that field (see above), it switched to <photoshop:Headline> as the Title. (I didn't bother to check what it would do if I emptied that one too.)
FYI, the program I used to get at this data was 'exiv2' from the Ubuntu package library. Basic method:
# -- extract IPTC data to .xmp sidecar file...
exiv2 -eiX <filename>.jpg
# -- edit <filename>.xmp
vi <filename>.xmp
# -- insert IPTC data from .xmp file...
exiv2 -iiX <filename>.jpg
Clearly, using the metadata to simplify content management by Zenp is a very valuable feature. I'm guessing someone has already written a plugin to enable editing this stuff (if not, maybe I'll write one when I get time).
Thanks again for the assist on multiple_layouts.
In any case, thanks for the explanation of the multiple_layouts. I built a custom script, and it worked perfectly.
There is in fact a plugin (`xmpMetadata`) that will allow you to get metadata from XMP files (or imbedded XMP in the image.)
My only suggestion: perhaps a 'lock-title/description' checkbox on the image properties to prevent metadata from overwriting custom content.
`
`
You can either print raw text from the CustomData field, or use the TinyMCE editor to compose html, then cut/paste the raw HTML into a Codeblock() like this:
`
<?php<br />
$my_var = <<<HTEXT<br />
(pasted raw html from TinyMCE>)
HTEXT;
echo $my_var;
?>
`
I actually like this solution better, since it allows you to toggle between the actual metadata and the custom content by selecting the layout file. The multiple_layout is elegant, powerful and obviates needless hacking of the original theme.