Plugins & Hacks

How can I get search results displayed in random order?

Scenario:
"I want to make search results be random in order so that the same search query will bring up results in a different order."

Solution:
This requires a small core hack to BLOG.php.

Original forum thread (thanks, xiffy!):
http://forum.nucleuscms.org/viewtopic.php?t=9416

Method:

  1. Find the function 'getSqlSearch' on lines 479 - 485 and you'll find the statement where the order is added to the search query.
  2. Replace line 482:
    $query .= ' ORDER BY score DESC';
    

    with

    $query .= ' ORDER BY RAND()';
    
section: Plugins & Hacks | submitted by Leng on 2005.Nov.18 | 2406 views

item rate
Total votes: 8 - Rating: 8.25

Please tell us how useful this answer was to you (0 = useless, 10 = very very helpful):

10