Display city and country on image.php

Hello :)

A little post to ask for tips from advanced users.

I am using the defaut template and want a simple page which display in this order:

- Menu
- Photo
- Title
- City, Country

Beside that I use Adobe Lightroom in which I fill those information (IPTC), I export my photos and upload them on my server.

I have already edited the defaut page to place the title under the photo by moving the following element under the image:

<?php echo getBareImageTitle(); ?>

I though it would be easy to do the same for city and country information within the documentation.

I placed the elements "<?php echo getImageCity(); ?>" and "<?php echo getImageCountry(); ?>"

But it seems to be a little more complicated. Which file must be modified? And in which way?

Thank you very much from France :)

Comments

  • acrylian Administrator, Developer
    It is actually the reight way to do. City an Country are standard fields of an image entry. You can check on the backend if there are values.

    But those are not the meta data fields you want. You get those using this function:
    http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functiongetImageMetaData
    It returns an array with those data you can then output. The listing of this actually is enabled via a button on all standard themes if there is such data.
  • I have added the element :

    <?php array getImageMetaData( [$image $image = NULL], [string $displayonly = true] )?>

    And when I open the page an error occurs:

    Parse error: syntax error, unexpected T_STRING, expecting '(' in /homez.150/mylastde/www/gallery/themes/default/image.php on line 80

    I still miss something.
  • acrylian Administrator, Developer
    Of course since that code is really wrong. In short you cannot directly output an array. You have to tell what field and value and then echo it.

    Sorry it really exceeds the limits of this forum to teach such things. You should now take the time to learn some PHP basics first before you try to modify a theme.
    http://www.w3schools.com/php/default.asp

    Also please see here:
    http://www.zenphoto.org/news/how-to-read-the-zenphoto-functions-guide
  • This is probably very unsophisticated code, but it works for me (fields are populated in Lightroom before upload):

    `
    <?php
    $country = (getImageData("country"));
    $state = (getImageData("state"));
    $city = (getImageData("city"));
    $location = (getImageData("location"));
    if ($country) {$country = $country . "\ ";};
    if ($state) {$state = $state . "\ ";};
    if ($city) {$city = $city . "\ ";};
    $place = "<strong>Place: " . $country . $state . $city . $location;
    ?>

    <?php echo $place; ?>

    `
  • acrylian Administrator, Developer
    It's not that bad actually but the outer brackets in `(getImageData("country"))` are unnecessary.
Sign In or Register to comment.