Using "alias" to do two different searches on two channel on result page
Hello,
I'm successfully doing a search on a channel, name it "A". You can find form here: https://pastebin.com/Sj7S6VJR
Now I want to do, on the same result page, a search on channel "B", but on two fields that have, in that channel, another name.
On the first search I've this field "child:cosa_incolla_relationship[]", on the second I want to search on two other fields, named "materiale_1" and "materiale_2", using both of the values passed in search.
A bit tricky, I know, I hope I explained it well.
Thanks.
Diego
Replies
Low 26 Jun 2018 13:21
If I understand correctly, the end result would be a list of entries that match Channel A with any given additional parameters OR channel B with the relationship and keywords that match field 1 OR 2.
If that is indeed the case, Low Search cannot do that out of the box. All parameters/filters are cumulative; combined with AND, as all parameters in EE are. You'd need custom filters to achieve anything specific and granular as you describe, I'm afraid.
Diego - Oltremedia s.a.s. 26 Jun 2018 13:42
There will be two results, the second one (the first one is ok) would be a list of channel B entries that matches two specific attributes coming from query. But in the query these two parameters have another name. So, am I supposed to use an alias in result tag?
Low 26 Jun 2018 15:46
If you have 1 parameter value that target 2 different params/filters, you could use an alias for both, to avoid one being picked up by the other.
For example, you could use the name
q
as a parameter and alias it tokeywords
in 1 results tag, andsearch:field
in another. That way, one or the other is targeted.Diego - Oltremedia s.a.s. 26 Jun 2018 16:19
Ok I give you an example.
Generated query now it's like
"/risultati?search:criteri_affinamento_0=Incollare+%2F+Riparare&child:cosa_incolla_relationship=pvc-rigido-laminati-plastici|alluminio"
Now, in the result page I have a result tag that has to search into "faq" channel for two fields, named materiale_1 and materiale_2, whose values I've in the query at "cosa_incolla_relationship". For the query I posted, so, I have to check for all "faq" entries that have "materiale_1" = "pvc-rigido-laminati-plastici" and "materiale_2" = "alluminio".
I made a query like that
{exp:low_search:results
query="{segment_3}"
channel="faq"
alias:materiale_1="cosa_incolla_relationship"
sort="asc"
}
but it does not works and I don't know how to go forward.
Thanks!
Low 26 Jun 2018 19:16
The alias option works only on full parameter names. So, using a query string like
and a Results tag like
...will treat the "prase" parameter as though it was "keywords", so searching for 'hello-world'. Using a part of a parameter will not work. So, having
will not work, as the parameter "materiale_1" does nothing nor is the parameter "cosa_incolla_relationship" in the query string. You're targeting parts of params. Instead, you'd need to use something like
but that (i think) can cause both parameters to be triggered. Instead, use an alias that can be explained 2 ways in 2 Results tag, so
and 1 results tag would contain
and the other results tag would contain
Diego - Oltremedia s.a.s. 29 Jun 2018 10:37
Thanks for your answer, it helped me!