Sorting results by date (ie; most recent post first) - could it be possible?
Dabitch - August 10, 2007 - 08:21
| Project: | SQL Search (Trip Search) |
| Version: | 4.7.x-1.6 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hi
I saw someone asked this question already - http://drupal.org/node/27374 - and got a simple no as an answer. Sorting results by date is not possible now. I'm looking for a search module that sorts results by date, most recently posted first, by default and was wondering if there is any way I could get this search module to do that , or if there are any plans of adding this feature. Having results returned by date is what most people expect from a search and I've been searching (heh) high and low for a Drupal module that does this.
I'm using trip search now and find no other issues with it, it would be perfect if it would just return by date.

#1
Am I to interpret the silence on this question as a "No"? (not being snooty, just genuinly wondering if I've missed something in my searches - someone replying would help.)
I've only recently switched over to Drupal and am, due to search not returning things by "most recently posted" date order - seriously regretting this. Users are emailing in to complain about the search almost daily, having been spoiled I guess with a search engine that returned items by date before.
It seems a pretty straightforward thing to have, when a user searched a website, the results are returned in the order they were posted, showing the most recently posted item first.
I'm curious as to why drupals search don't do this, and why nobody seems interesting in adding such a feature. Am I the only one who would like this (apart from my users)?
How hard would it be to do? Is it difficult?
#2
http://drupal.org/node/13771#comment-948601
I used the trick from the above comment in Drupal 5 and it worked exactly as I wanted it to:
in file node.module placed in node module folder at line 925 you must change this code :
/modules/node/node.module line 925:
<?php// Do search
$find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid '. $join1 .' INNER JOIN {users} u ON n.uid = u.uid', $conditions1 . (empty($where1) ? '' : ' AND '. $where1), $arguments1, $select2, $join2, $arguments2);
?>
to this code:
<?php// Do search
$find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid '. $join1 .' INNER JOIN {users} u ON n.uid = u.uid', $conditions1 . (empty($where1) ? '' : ' AND '. $where1), $arguments1, $select2, $join2, $arguments2,'ORDER BY n.created DESC, score DESC');
?>
However, I am now on Drupal 6 and back at wondering why on earth Drupal search doesn't return results based on most recent date. The trick also works in six but the line that needs changing is further down in the module.
#3
It's a bit tedious that I have to remember to do this every time the core is updated.
#4
That's the trouble with hacking core.