Low Search and multiple child relationships
Hi there. I’m trying to use Low Search to accomplish something, and I think it’s my best option as far as add-ons go, but maybe you can help point me in the right direction or let me know if what I’m trying to do is possible with the Low Search.
Scenario:
Users are logging into another system. That system is re-directing users to EE with 3 URL parameters: audience type, audience division, and audience state. I need to show appropriate content for those 3 parameters. So, I’m not using Low Search as a site search so much as a way to filter content on page load. You can also read more here, where Mark Croxton introduced me to the idea of using Low Search for my scenario: http://devot-ee.com/add-ons/support/s...
The URL query will look something like this:
http://www.mysite.com?audience=instit...
The 3 parameters represent 3 distinct channels (I’ll call these audience segmentation channels). I’m using these audience segmentation channels as relationship field on my content channels, much like categories. (Side note: I’m not opposed to using categories if that’s going to be the better approach)
I have a handful of content channels on this site, each of which needs to have their content filtered based on these 3 parameters. I’ll just use the “updates" channel as an example, which just provides short customer updates at the top of the site. For the URL above, I would need to show updates entries that are “tagged” (or segmented) for the “institutional” audience, the division that has an entry ID of 56, and the state of Georgia. Each update is segmented with an audience type, a division, and a state, using the relationship fields. The user can also decide to segment the content for all audiences, all divisions, and all states.
Here is what one of the Low Search Results tags looks like right now:
http://pastie.org/9576549
As you can see, I’m using the “child" parameter on all 3 child relationships. (The piped entry_ids in the parameters are the relationship field entry for “all audiences”, “all divisions”, and “all states”.)
The problem I’m running into is the one that Mark Croxton mentioned in this comment: http://devot-ee.com/add-ons/support/s... where the filters are progressively applied.
Say a piece of content is segmented with the following relationship fields chosen:
Audience: Retail
Division: New York Metro
State: New York, New Jersey, Philadelphia
And say the user was redirected to the EE site with the following query: ?audience=retail&division=56&state=ga
Since the state does not match just one of the states that the piece of content was segmented for, it does not display. The audience type is the only one that should be restrictive. The others can actually be somewhat flexible. So, if *either* the state or the division has a match, the piece of content would show. In my case, it doesn’t show, because there’s only one match for the division, but not the state.
I can see that this isn’t possible with the relationships filter. Is it possible with categories? Do I need to look into another solution? Every content channel on my site needs to be filtered by the given options in the URL query this way.
Thanks!
Replies
Low 20 Sep 2014 09:13
Indeed, using 3 child:field params will always combine the 3 with AND; the way EE uses parameter is always "cumulative".
You could work around it by using categories, as you can make arbitrary groups there. For example: category:audience="1|2|3" category:other="4|5|6" -- here the first param would contain the category IDs for audience, and the second param would contain both division and state category IDs.
wjthomas9 20 Sep 2014 18:24
Bummer. I was afraid categories might be the only alternative way to re-use these 3 fields across multiple channels. I'll already be using categories for the normal things, like news categories etc, so that's really going to add a lot to the category interface for each content channel.
I suppose I could write one or three custom fields to capture these 3 segmentation options. If I did that, do I have the same flexibility with Low Search on custom fields as I would with categories? I *did* get to attend a pretty sweet workshop on building custom field types at Peers. ;) Might be a good candidate to try my hand at it since it's really just 3 select dropdown fields.
Thanks for the help, Low.
Low 21 Sep 2014 09:47
Using 3 custom fields will have the same restriction as using 3 relationship fields. You're targeting the 3 fields using 3 parameters, which means they're all combined using AND. If you're using categories instead, that is in fact just 1 "field", with arbitrary grouping.
There are custom fields available that generate a different interface for using categories, tho. Like this one: http://devot-ee.com/add-ons/categories-field
If you are
wjthomas9 22 Sep 2014 14:00
I see. Categories it is for now, then. Thanks.