related items v0.9.1

Release Notes

0.9.1: fixed: php warning relating to array

fixed: view of matching tags was not showing correct tags

  • Feature request: Could you change the ranking of the related items based on number of views, so tags first and then rank on views. There is a plugin views_counter which already does the counting.

  • i stopped using the view counter plugins when i found them to be counting twice in some circumstances. this has not been fixed as far as i am aware

  • That wasn't a problem with the views counter plugin, it was that you were actually calling the view multiple times via ajax

  • i had in the 'back of my mind' an idea that some kind of cause was found, but i forgot what it was. i don't recall the issue being ajax related. i recall that maybe firebug was involved or some other code inspector...

    but whatever it was, i obviously never resolved it completely because i left both the view counter plugins i have tested disabled. maybe i will look at this again when i get a chance.

  • oh ok, i do not use topics on my site, so i haven't tested related-items with topics much. which version of elgg are you using?

  • Thank you for this useful plugin.

    Would it be an idea to have a 3rd way in addition to "More items" and "Related items": A way which gives priority to "Related items" but when there are less than the [Maximum number of related items to show], then complements the list with "More items"?


  • it's certainly an idea, yes! ;)
    there are several options like that which could be added. maybe once i get my site upgraded to 1.9+ i will look at this.

  • Great plugin - but I'm getting an error when clicking on a group discussion topic...

    Fatal error: Call to a member function getSubtype() on a non-object in /home/content/59/8407459/html/elgg/mod/related-items/views/default/related-items/related-items.php on line 3

    Any idea what he cause of this could be?


  • @knussear - which version of elgg are you using? that message infers that the $vars variable is not available to the related items view in that discussion context. i have tested here with the latest elgg 1.8 and i am not seeing that error.

  • @ura soul Same for me as @knussear on elgg 1.9

    $vars array has no entity key so getSubtype() fails. 

  • replacing -> in /home/content/59/8407459/html/elgg/mod/related-items/views/default/related-items/related-items.php on line 3



    if(!empty($vars['entity']) && in_array($vars['entity']->getSubtype(),$renderto_subtypes))

    solves the problem, but don't know if the plugin still has its funcionality

  • I guess it's not coz on line 2:


    gets no value

  • i still haven't upgraded my site to 1.9 here because other key plugins are not available for 1.9. therefore i haven't updated my own plugins for 1.9. i am about to start though, so i'll look at related items first.

  • ok, if I have enough time to migrate it, let you know

  • i did already upgrade this plugin to an early version of 1.9, but obviously more issues have arisen since then.. so most likely there won't be much to do.

  • This is what I've done to make it work. 

    At the beginning of views/default/related-items/related-items.php (where the error is), added a function call to add entity to $vars, and added a new condition on if to check that entity is not empty and avoid the error:

    if(!empty($vars['entity']) && in_array($vars['entity']->getSubtype(),$renderto_subtypes))


    At the end of lib/related-items-lib.php the function invoked above:

    function create_vars_entity(&$vars) {
       $class_types = array('ElggObject');
       if (!empty($vars['entity']) || !preg_match('/^1\.9(\.[0-9]{1,2})?$/', elgg_get_version(true))) {
          return false;
       foreach ($vars as $var) {
          if (gettype($var) === 'object' && in_array(get_class($var), $class_types)) {
             $vars['entity'] = $var;
       return true;

    And also added this item to language files:

    'related_items:discussion' => 'discussion',

    Not sure if this will imply any behaviour errors, if anyone notices some just let me know to fix'em.


  • looks like you are searching for the object within the $vars array, rather than calling it directly. i will look at this soon here.. the heating has broken in the house here, so programming is not so fun!

  • Yes, I'm copying the ElggObject that stores de elgg entity of the group_forum_topic and copy it as $vars['entity'], because in the rest of the cases its stored in $vars['entity'] so the rest of the view code does not break. 


    A cleaner way would be store the var depending on the entity and use that variable along the view code, but I needed a quick fix for this, we're going on production tomorrow and gotta migrate an old 1.7 elgg to a 1.9.


    Let me know if you repair your house heating and fix this issue better :)



  • oh ok, so this appears to be a bug/inconsistency with the discussion code, rather than related_items per se.
    i stopped using discussions on my site, so didn't test it much. i'll look at this now.

  • i've tested this in 1.8 and it is working fine with no changes.. onto 1.9.

  • i did have a fix for this, however, my hard drive failed and i am not sure yet if i need to re-code the solution.
    i will look at this again soon.

  • @ura Soul: Will this plugin be available in elgg 1.9 ??

  • yes, this will be released as a fixed and tested version for 1.9 and 1.10 in the near future.

ura soul

co-creator of reality - admin of an online social network for healing, balancing & evolving.. plus maker of some free plugins for elgg


  • Category: Misc
  • License: GNU General Public License (GPL) version 2
  • Updated: 2016-8-9
  • Downloads: 5557
  • Recommendations: 26

Other Projects

View ura soul's plugins