![]() |
|
Howto Select an alternate layout - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: Howto Select an alternate layout (/thread-10906.html) |
Howto Select an alternate layout - randyjames - 2013-03-10 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_.php ...what is 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. Howto Select an alternate layout - sbillard - 2013-03-10 I presume you are talking about using the 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. Howto Select an alternate layout - acrylian - 2013-03-10 The plugin entry has some info about that as well: Our recenlt server migration resulted in some still unsolved encoding issues in case you wonder about some weird chars in the text. Howto Select an alternate layout - randyjames - 2013-03-10 Thank you. It worked perfectly. I'm not sure if I did this or simply overlooked it when I enabled multiple_formats, but the image.php type was not selected in the multiple_layouts config, while the 'pages' 'news' and 'news categories' were. Otherwise, I would have noticed the layout selection option on the image properties admin screen when I created the original alternate script. A very clean and versatile solution to customizing theme behaviour. 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):
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.
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): `
` 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 .jpg -- edit .xmpvi .xmp -- insert IPTC data from .xmp file...exiv2 -iiX .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. Howto Select an alternate layout - randyjames - 2013-03-10 Well, I posted a lengthy reply with a "thank you" and some useful information about metadata and image files, but I don't know if it got through or not. It had some markup from a .xmp file in it, so maybe that didn't go through. In any case, thanks for the explanation of the multiple_layouts. I built a custom script, and it worked perfectly. Howto Select an alternate layout - sbillard - 2013-03-11 Yes, lengthy posts will get caught. See http://www.zenphoto.org/support/topic.php?id=43854. But they can be retrieved upon request (so long as we can find them in all the chaff.) I have revived your post. Quote: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. Quote: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 Quote: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. There is in fact a plugin ( Howto Select an alternate layout - randyjames - 2013-03-11 Thanks for all that follow-up. Very helpful. My only suggestion: perhaps a 'lock-title/description' checkbox on the image properties to prevent metadata from overwriting custom content. Howto Select an alternate layout - randyjames - 2013-03-11 BTW, it's real easy to use an alternate layout to resolve issues related to metadata vs. custom content. I changed one line from the original image.php file: ` ` 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: ` ` 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. Howto Select an alternate layout - sbillard - 2013-03-11 Quote:My only suggestion: perhaps a 'lock-title/description' checkbox on the image properties to prevent metadata from overwriting custom content |