node.module's advanced search options let you filter by keyword, category, or type, but they do not let you change the output sort order. search.module already supports changing the sort order, so it is easy to add.

Patch for 4.7.3 and HEAD attached (same file).

Comments

airblaster’s picture

Version: x.y.z » 5.0-rc2

I think this should be added to drupal as soon as possible.
Would probeably help to avoid lots of unnecessary double posts in the support forums!

add1sun’s picture

Version: 5.0-rc2 » 5.x-dev
StatusFileSize
new2.81 KB

This works fine for me so I rerolled it against HEAD. This is a great little addon so it would be cool to into core, if possible, since I am sure I will end up using this patch on number of sites.

RobRoy’s picture

Status: Needs review » Needs work

Code style issues:

- array should be

$foo = array(
'#value' => 'blah',
);

- Inline comments use // and sentence capitalization with a period
- Those strings should use t() and need sentence capitalization maybe (or lowercase if the other stuff on the form is like that)

RobRoy’s picture

Version: 5.x-dev » 6.x-dev

Going to wait for 6.x-dev.

RobRoy’s picture

- If block indentation needs another space
- And cases should be indented from switch

Steven’s picture

Status: Needs work » Closed (won't fix)

You can already have search results by date by configuring the ranking in the administrator area. IMO this is not something that the end-user should have to change. If your site has lots of new content, set up the sort order that way.

bjaspan’s picture

Status: Closed (won't fix) » Reviewed & tested by the community
StatusFileSize
new2.91 KB

Sorry, doctor, but I'd like a second opinion. :-)

Setting the search results sort order via the admin settings is insufficient. We have an 'Advanced search' form for a reason. Sometimes users want to control the type or terms of the results, and sometimes they want to control the primary sort key. Why refuse them that option?

add1sun has supported the patch and confirms it works. I have applied RobRoy's code style fixes (except for "if block indentation needs another space"; all if blocks in the file use two-space indent, just like my patch) and re-rolled the patch for HEAD.

Steven’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

Do not set your own patches to "ready to be committed". Your patch does not even conform to code style.

It arbitrarily adds date sorting options, while completely ignoring the other options that node search has. If you want a sort UI for end-users, it should allow all sorting options, or none at all. Plus, the proposed solution is very inflexible. If I already set up my site to sort by date, I end up with a useless control (as 'score' will be the same as 'newest first').

I'm not against sorting options per se, but it needs to be done properly, in a flexible and usable manner. This patch is just a hack, and as the maintainer of Drupal search I don't like it.

RobRoy’s picture

Regarding that if block, the problem is that you're using TABs instead of 2 spaces.

http://drupal.org/node/318

Anonymous’s picture

Version: 6.x-dev » 7.x-dev
Status: Closed (won't fix) » Active

I'm reopening this issue in support of http://groups.drupal.org/node/16078. I don't think we should limit the functionality of the advanced sort to the administrator. Let's see if we can roll a patch for D7.

Anonymous’s picture

Component: node system » usability

Making this a usability issue.

cameron tod’s picture

Component: usability » ajax system
Status: Active » Closed (duplicate)

Shall we close this, now that Views is in core for D8?