Order by collection
Hi Low,
Is it possible to display the results by collection?
My client has a global site search displaying results for three channels/collections: articles/pages/events
They’d like the events (built using Low Events) at the top of the list ordered by the Low Date.
Then everything else afterwards display by relevance.
I did think of having to separate results tags, however, this wouldn’t allo pagination.
I have tried using the following code to define a custom order:
orderby="cf-event-dates|low_search_score" sort="asc|asc"
However, the results from the the pages collection appear first. I guess that’s because they don’t contain the custom date field.
Is there any way to control the grouping of collections in this way?
If not, would the only solution be to build a collection filter on the search form?
Sorry if this is a silly question. First time using Low Search.
Simon
Replies
Low 7 Mar 2013 12:36
Ordering by collection isn't possible, I'm afraid. Also, combining ordering by score and something else isn't possible either. You either order by score or something else, like the native channel:entries tag.
Building a collection filter is definitely possible, yes. You could add some JS to change an orderby field (or orderby_sort field).
thoughtful_web 7 Mar 2013 14:57
Thanks Low.
I’ve created a collection filter on the results page. BTW, Filters are a fantastic new feature!
In regards to the JS. I’m not sure about the best way to approach this. Would you suggest appending an orderby param to the search string and reload the page? Is this even possible? Or would you suggest a different method?
Sorry to ask so many questions. This has not been the easiest of builds.
Thanks for you help.
Simon
Low 7 Mar 2013 15:15
Well, if you're using the filters (i.e. URL tags) to alter the search results, then you could take the sorting into account without the need of JS. I was thinking in terms of the search form, where you can select which collection you want to search through, and based on which collection is selected, populate a hidden orderby="" parameter. But filtering after the search itself works too.