Limit number of related articles returned in Joomla 1.7 and Joomla 2.5

Submit to reddit

Joomla 1.7 has a nice module mod_related_items (Articles Related) that shows articles related to the current one the visitor is browsing. It has one issue though, you can’t set a limit.

So a little code hacking is in order. Open modules/mod_related_items/helper.php and go to line 94 (right after the Filter by language if) and modify $db>setQuery($query); to read:

$db->setQuery($query,0,10);

Of course you can change the limit from 10 with whatever you like. Random order is commented out because using ORDER BY RAND has performance issues. If you think you can handle it feel free to uncomment.

This hack also works for Joomla 2.5!

Homework:

  • add parameter in the admin interface Feel free to post the solution 🙂
  • Tusi

    Hi!
    It’s work fine in Joomla 2.5+ too:

    Open modules/mod_related_items/helper.php and go to line 108 and modify
    $db->setQuery($query);
    to:
    $db->setQuery($query,0,10);

    Best regards,
    Tusi
    http://www.facebook.com/tusilike