Member
Member
NaturalEnquirer   2012-08-29, 23:36
#1
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?
Member
Member
sbillard   2012-08-29, 23:42
#2
When pages are "killed" there is always an error message. That message would be critical to understanding what is wrong.
Member
Member
NaturalEnquirer   2012-08-30, 00:20
#3
It generate a 500 internal server error ... No errors in zenphoto debug log.
Member
Member
sbillard   2012-08-30, 02:03
#4
Nothing in what yo show that should cause a 500 error. Maybe it is how you inserted the code or where you inserted it.
Administrator
Administrator
acrylian   2012-08-30, 07:25
#5
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.
Member
Member
NaturalEnquirer   2012-08-31, 16:25
#6
Thank you for pointing me toward the hasTag() function. This is what worked for me:

`
<?php
if($_zp_current_image->hasTag("Federally Endangered")) { ?>
[list][*]<?php echo "This species is federally Endangered."; ?>[/list]
<?php }
`
Administrator
Administrator
acrylian   2012-08-31, 16:51
#7
Exactly how it should be used..;-) This works with all objects of albums, Zenpage pages and articles, too.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.