ZenphotoCMS Forum
printRelatedItems empty - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: printRelatedItems empty (/thread-11618.html)



printRelatedItems empty - SubJunk - 2014-02-05

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?




printRelatedItems empty - acrylian - 2014-02-05

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




printRelatedItems empty - SubJunk - 2014-02-07

Sorry I should have said this before, I was using it like this:

printRelatedItems("5", "images");

I also tried specifying all params but it was still blank




printRelatedItems empty - acrylian - 2014-02-07

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).




printRelatedItems empty - SubJunk - 2014-02-07

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




printRelatedItems empty - acrylian - 2014-02-07

Actually looks correct. Please take a look at your search options. Are maybe images disabled for results? It should not make any difference as the plugin should bypass that.

I will try to reproduce later today.




printRelatedItems empty - SubJunk - 2014-02-09

Images aren't disabled for search results, thanks for trying to reproduce




printRelatedItems empty - acrylian - 2014-02-09

I am sorry to report that it works for me as intended with images.




printRelatedItems empty - fretzl - 2014-02-09

Works for me too.




printRelatedItems empty - fretzl - 2014-02-09

Have you tried to set the "Cache expiry" to 0 (zero) in admin => options => search ?




printRelatedItems empty - acrylian - 2014-02-09

Good tip, forgot the search cache completely!




printRelatedItems empty - SubJunk - 2014-02-10

Thanks for trying to reproduce it. I changed the search cache to 0 but it still doesn't work for me. I checked the error logs and can't see any related errors.




printRelatedItems empty - SubJunk - 2014-02-20

Could it have something to do with the PHP version? I'm running 5.3




printRelatedItems empty - acrylian - 2014-02-20

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.




printRelatedItems empty - SubJunk - 2014-02-22

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




printRelatedItems empty - SubJunk - 2014-02-22

I made it work by removing lines 118 and 120 in related_items.php, it wasn't passing either of those conditions. Hopefully that helps narrow down the cause.




printRelatedItems empty - acrylian - 2014-02-22

Hm, I would need to reproduce it… Those lines actually do just check on which theme page you are and what item type to get the related items of. A current iamge is always set on an image.php page.




printRelatedItems empty - SubJunk - 2014-02-22

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.




printRelatedItems empty - acrylian - 2014-02-23

No, indeed there is no reason. Looks like a clear oversight on the images check.