Forum

Notifications
Clear all

[ SOLVED ] Advanced search only displays alphabetical results

SJP
 SJP
(@sjp)
Trusted Member

A member on my site noticed that the advanced search function will only display stories in alphabetical order, even when Most Recent is selected as the sort option. I searched the forum and found this post in solved bugs: http://efiction.org/forums/index.php?topic=5548.msg30639#msg30639. It seems this was noticed before, but the last post in the thread says that it was fixed with version 3.5. I am using 3.5.3 and still have the error, so I'm not sure why it was marked as fixed. Does anyone have the advanced search most recent sort working properly? Did you have to add anything to the code to get it working that way? Any help you can provide would be greatly appreciated.

UPDATE: After playing around with the search for awhile, I discovered that it can sort by most recent, but only if the member has their default story set to most recent. When they have most recent selected in their preferences, the search results wont display alphabetically, even when they choose that sort option in the advanced search page. When someone who is not logged in tries to search, it will only sort by the site default (which in my site's case is alphabetical-the reason I couldn't search by most recent before). Any idea how to override the site/user settings and search the way the user selects on the search page?

Quote
Topic starter Posted : 20/06/2013 6:52 pm
SJP
 SJP
(@sjp)
Trusted Member

Sorry that you all have to witness a conversation that I'm having with myself, but I think I figured out a solution, and I wanted to share it in case anyone else wanted to add it to their sites.

The problem was in line 230 of search.php

$query = (count($query) > 0 ? " AND ".implode(" AND ", $query) : "")." "._ORDERBY;

I changed it to

$query = (count($query) > 0 ? " AND ".implode(" AND ", $query) : "")." ORDER BY ".($_REQUEST['sortorder'] == "alpha" ? "stories.title" : "updated DESC");

and now the search sort seems to be working as it should.

ReplyQuote
Topic starter Posted : 21/06/2013 4:16 am
Share: