Low Search using playa relationships
Low,
I'm stuck on how best to proceed with what I need to do.
I have a channel TRIPS where I need to set up various filters/search links based on playa relationships within the channel entries. So I'd have search links that visitors could click for each of the following where each river/activity is a channel entry in their own channel.
River
- river one
- river two
- river three
Activity
- activity one
- activity two
-- activity three
What I've done so far is set up a "Trips" collection and now I need to be able to filter all trips so that only those with a related river one or related activity two will show on the results page.
How do I proceed with this? I've looked at the docs but am not sure exactly what to do.
Replies
Low 9 Feb 2016 22:10
As you might expect, you will need the Relationships filter. Exactly how you use it, depends on your setup.
You want to display Trips as search results. If in the Trips channel you select a River, then the River entry is the child of the Trips entry, so you want to display Trips that have the selected River entry as a child:
child:playa_field="x"
(where x is the River entry ID).The other way round, if in the River channel you select a Trip, then the River entry is the parent of the Trips entry, so you want to display Trips that have the selecte River as a parent:
parent:playa_field="x"
I'm guessing the former is the case here, so the first example applies, where the Shops == Trips and Pizzas == Rivers (or Activities).
Sean 10 Feb 2016 14:25
Low,
That makes sense - is it possible to do all that with the url tag as I've got an unordered list of links rather than a form?
Low 10 Feb 2016 14:54
Yeah, definitely possible. Just set the parameter on the URL tag to generate a link to that query.
Sean 12 Feb 2016 15:58
Low,
I've made progress with this but the search results are outputting all entries in all channels.
The links to filter are generated by the following code
On the search result page I'm embedding a google map using Gmaps with this embed code
The embedded template is here:
Where the {title} tag outputs every single title in all channels when it should only output the 2 or 3 that have set a relationship to hat activity type in the first code block.
Low 13 Feb 2016 09:39
You've got
child:playa_field="trip_activity_type"
The Relationships filter doesn't work that way. Read this bit again: http://gotolow.com/addons/low-search/...
Following those rules, the parameter should probably look like this:
child:trip_activity_type="1"
, where 1 is an entry ID. That means you can use {entry_id}, as you're using it inside a channel:entries tag.Use
toggle:child:trip_ativity_type="{entry_id}"
if you want to be able to have multiple selections, see http://gotolow.com/addons/low-search/...Sean 16 Feb 2016 15:05
Low thank you for clarifying. using toggle is exactly what I needed and I am embarrassed that I didn't replay playa_field with the field name...