printRelatedItems empty

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?

Comments

  • acrylian Administrator, Developer
    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
  • 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
  • acrylian Administrator, Developer
    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

    `
    `<?php`
    `if (function_exists('printRelatedItems')) {`
    `printRelatedItems(5, "images");`
    `}`
    `?>`

    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 :)
  • acrylian Administrator, Developer
    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.
  • Images aren't disabled for search results, thanks for trying to reproduce :)
  • acrylian Administrator, Developer
    I am sorry to report that it works for me as intended with images.
  • fretzl Administrator, Developer
    Works for me too.
  • fretzl Administrator, Developer
    Have you tried to set the "Cache expiry" to 0 (zero) in admin => options => search ?
  • acrylian Administrator, Developer
    Good tip, forgot the search cache completely!
  • 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.
  • Could it have something to do with the PHP version? I'm running 5.3
  • acrylian Administrator, Developer
    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 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.
  • acrylian Administrator, Developer
    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.
  • 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.
  • acrylian Administrator, Developer
    No, indeed there is no reason. Looks like a clear oversight on the images check.
Sign In or Register to comment.