I've enabled the related_items plugin and tried to use printRelatedItems() and getRelatedItems() in a theme but they return nothing - getRelatedItems() returns an empty array and printRelatedItems() doesn't print anything.
I've added tags to the image pages I'm testing, and other images share the same tags so I think it should match.
Is there something else I need to do to use the plugin?
By default relatedItems gets those for Zenpage news articles. You have to set the parameter correctly:
http://www.zenphoto.org/documentation/plugins/_zp-extensions---related_items.php.html#functiongetRelatedItems
The first parameter is an integer so no quotes needed. Are you really sure your images are published and not protected otherwise and also have tags set?
We have to try to reproduce it. We are using it with articles on our own site and that at leat for sure works. (the display part is a modification for the theme though but besides that it is the same).
I haven't tried with news articles, but here's a vanilla installation of zenphoto 1.4.5.8 where all I've done is add images, give them all the same tag ("arrow"), enable the related_items plugin and add the following code to the default theme's image.php:
`Related`
``
Link: http://beta.dualmonitorbackgrounds.com/test4/index.php?album=SubJunk&image=AnonWorld.jpg
I guess I'm doing something obviously wrong but can't see it
I really doubt that although I primarily test on PHP 5.4 but it should really not make any difference. All this plugin does is do a manual tag search directly, so basically the same that happens if you click on a tag (which apparently works above). Are all images/albums tested published? Other than that I have no idea, sorry.
Yeah they're published. I also tried with a fresh install of the latest 1.4.6 code (45abde6) and got the same results: http://beta.dualmonitorbackgrounds.com/test-45abde6/new-album/3rdRockFromTheSun.jpg
You can click the tag and it does the tag search properly like that, but still the related part is empty.
I'll try looking into it more
I see what it was now. The last part of the condition on line 118 ($current->getAlbum()->name != $item['folder']) prevents it from returning related results from the same album as the source image, and I was only using that tag within one album.
Is there a reason for disregarding related results from the same album? I think for a lot of people, tags tend to cluster with albums, so it may not be a condition that always makes sense.