Only show "Place" text if not empty

Could anyone help me out how to rewrite this bit from template-functions?
I want the script to print `

echo getAlbumPlace();

` as the `printAlbumPlace()`, but only if there actually IS anything written in the "Place" field. Otherwise, print nothing.

`function getAlbumPlace() {

global $_zp_current_album;

return $_zp_current_album->getPlace();

}

function printAlbumPlace() {

echo getAlbumPlace();

}`

It's because I want to use Zenphoto to show my travel photos, AND my portfolio - both pages which need a slightly different layout. So I want the `

echo getAlbumPlace();

` only to show on the travel-photos pages. Reason why I include the h3 tag is because there's a background image involved, which otherwise would stay awkwardly empty, in the non-travelphoto pages!
Many thanks in advance:)

Comments

  • trisweb Administrator
    `<?php $place = getAlbumPlace(); if (!empty($place)) { ?>

    <?php echo getAlbumPlace(); ?>

    <?php } ?>`

    That should do it! Let us know if you need more help.
  • Works wonderfully, thanks very much!

    I've spent days looking for a simple image gallery script (after deciding I didn't want to use a Lightbox-like script) and in the end I tried out Catscan (http://cat-scan.net/) and Cligs (http://johnleach.co.uk/documents/cligs/index.html). But both these projects had so little documentation that I turned to Zenphoto (which I didn't want to do in the beginning because I'm kind of afraid of SQL and scripts that consist of more than one file). Well, now I'm very happy that I did :) Thanks again!
Sign In or Register to comment.