SimpleSearch sort results by published date

Hi all, I must be missing something here - but how is it possible to display search results from the SimpleSearch extra in chronological order with the newest at the top? e.g. so when it find results that match the search term, all those that match are the returned results, but they are listed with the most recently published at the top and the oldest at the bottom? Thanks

The SimpleSearch snippet has the two properties sortBy and sortDir that you can use for that.

looking at > SimpleSearch - SimpleSearch | MODX Documentation it states “SortBy - A comma-separated list of Resource fields to sort the results by. Leave blank to sort by relevance and score.” Will it work with other parameters?

Whats the parameter? publishedon ? That’s not working - might be because we are using it to return a list of articles posts rather than resources?

publishedon should work.
“Articles posts” are also resources. So it shouldn’t make a difference.

OK, no change to the ordering of the results unfortunately…

Make sure that the capitalization of the properties is correct.
Lower case s and upper case B in &sortBy.

[[!SimpleSearchForm]]
<h2>Results</h2>
[[!SimpleSearch?
    &sortBy=`publishedon`
    &sortDir=`DESC`
]]

Bingo - I had a lowercase b in sortBy - thanks :wink:

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.