Howto Select an alternate layout

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

  • I presume you are talking about using the `multiple_layouts` plugin and have it enabled.

    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.
  • acrylian Administrator, Developer
    The plugin entry has some info about that as well:
    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.
  • 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):

    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.
  • 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.
  • 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.
    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.

    When Zenphoto sees the file has changed it does update the metadata it stores. I suppose that this could be changed, but it might be annoying. Perhaps a well thought out feature request issue is in order.
    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

    We do set the title from one of these fields if they are present: `IPTCObjectName`,`IPTCImageHeadline`,`EXIFDescription`. So perhaps those are not set in your metadata.
    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.

    The above sequence of fields is the priority for selecting the title. Other fields have similar priorities. If a greater priority field is empty the selection reverts to the lessor priority fields, so you have to eliminate all of them.

    There is in fact a plugin (`xmpMetadata`) that will allow you to get metadata from XMP files (or imbedded XMP in the image.)
  • 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.
  • 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:

    `



    <?php printImageCustomData(true); printCodeblock(0); ?>


    `

    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.
  • My only suggestion: perhaps a 'lock-title/description' checkbox on the image properties to prevent metadata from overwriting custom content
    This does exist, you can disable processing any of the metadata items on the image options tab.
Sign In or Register to comment.