Check for specific tag

I would like to print some information on the image page only if a certain tag exists for an image. E.g. If an image is tagged as a plant, I'd like to include its endangered status.

After reading several posts, it seems I should be able to do somehing like this:

`
<?php
if (in_array('Flora',getTags()) {
echo "Got It";
}
?>
`
This kills the page. As I don't know PHP, could someone correct what I am doing wrong?

Comments

  • When pages are "killed" there is always an error message. That message would be critical to understanding what is wrong.
  • It generate a 500 internal server error ... No errors in zenphoto debug log.
  • Nothing in what yo show that should cause a 500 error. Maybe it is how you inserted the code or where you inserted it.
  • acrylian Administrator, Developer
    Btw, there is an object model method for checking a tag:
    http://www.zenphoto.org/documentation/classes/ThemeObject.html#methodhasTag

    Again we have a documentation and try hard to name all function after what they do.

    A 500 internal error I don't understand as well but on some later PHP 5 versions it might cause a notice to pass "getTags()" directly. Preferred is to first put the value into a var.
  • Thank you for pointing me toward the hasTag() function. This is what worked for me:

    `
    <?php
    if($_zp_current_image->hasTag("Federally Endangered")) { ?>
    • <?php echo "This species is federally Endangered."; ?>
    <?php }
    `
  • acrylian Administrator, Developer
    Exactly how it should be used..;-) This works with all objects of albums, Zenpage pages and articles, too.
Sign In or Register to comment.