0

By default, I want my Low Search results to display with an orderby_sort of last_name|asc:

{exp:low_search:results
    collection="my_collection"
    default:orderby_sort="last_name|asc"
}

But when a keyword is present, I want the search results to be displayed by relevance.

I tried using a conditional around the orderby_sort parameter above like this:

{if low_search_keywords}orderby_sort="low_search_score|asc"{if:else}default:orderby_sort="last_name|asc"{/if}

But this does not seem to work.

1 Answer 1

0

Parameters like that won't work for various parse order reasons. Right now, it's not possible to achieve with just hard-coded params. However, you could use a hidden input field for the orderby_sort parameter in the form, and populate it with one or the other using JavaScript, based on whether the keywords field was empty or not.


Edit: In the latest version, it should be possible to define the sort order like this: orderby="low_search_score|title" sort="desc|asc". When no keywords are given, the results should be ordered by title.

1
  • This does not seem to actually work in practice with the latest EE 2.x version. Tried: orderby="low_search_score|url_title" sort="desc|asc", but Low Search does not then display by search score on a keyword search. It works fine if you remove the url_title orderby parameter, though. Jun 16, 2016 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.