Can anyone help me wrap my head around the pro_search features for sorting and ordering? I understand from the Pro Search - Filters documentation that there is supposed to be a function for that instead of only ordering by score. But it hasn’t worked for me so far … thank you so much in advance for any help on this.
EXAMPLE
I have come up with three collections in the Pro Search settings. Let’s call them ps_alpha, ps_beta, ps_gamma with according names Alpha, Beta, Gamma respectively. What I would like to achive is a search result in the form of:
Alpha
- Result Number 1 from Alpha (high score)
- Result Number 2 from Alpha (mid score)
- Result Number 3 from Alpha (low score)
Gamma
- Result Number 1 from Gamma (high score)
- Result Number 2 from Gamma (mid score)
- Result Number 3 from Gamma (low score)
Beta
- Result Number 1 from Beta (high score)
- Result Number 2 from Beta (mid score)
- Result Number 3 from Beta (low score)QUESTIONS
(1) Where would I need to give pro_search the filter settings?
Rather in the FORM tag, such as {exp:pro_search:form result_page="search" orderby="pro_search_collection:ps_alpha,ps_gamma,ps_beta"}
Or in the RESULTS tag, such as {exp:pro_search:results query="{segment_3}" orderby_sort="pro_search_collection:ps_alpha,ps_gamma,ps_beta|asc"}
(2) How would I “loop” through the search results, inserting headers for the collections at the first occurence of a search result from an individual collection?
I think I found a solution, at least for question number (1) … gotta say though that the current documentation is just a bit misleading, but in fact the orderby-parameter works with the result tag too, other than stated here Pro Search - Tags.
As for question number (2) I did not really follow my intetion, but as a hint: it’s possible, of course, to do conditionals in regards to the {pro_search_collection_name} variable / parameter for instance.
So for anyone visiting this later on, maybe this is helpful:
{exp:pro_search:results query="{segment_3}" orderby="pro_search_collection:ps_alpha,ps_gamma,ps_beta"}
{if pro_search_collection_name == "ps_alpha"}
// do things with results from collection ALPHA
{if:elseif pro_search_collection_name == "ps_gamma"}
// do things with results from collection GAMMA
{if:elseif pro_search_collection_name == "ps_beta"}
// do things with results from collection BETA
{/if}
{/exp:pro_search:results}Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.