Plugin

Developer
Supported

Search Fields

ExpressionEngine 1.x, ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Mark Croxton

1 of 2
1
   

You must be logged in to post.

Related Entries

General

Kyle Cotter
Kyle Cotter

Can this search through a related entries field?

Thanks!

Mark Croxton
# 1
Developer
Mark Croxton

In afraid not, sorry. I seem to remember someone mentioned doing this a while back (can’t remember who) so might be worth asking on twitter.

Jon Thomas
# 2
Jon Thomas

@Kyle, do you recall what direction you went here? I need to do something similar. Basically using relationships as categories to “tag” content so I can match entries to URL query parameters.

Mark Croxton
# 3
Developer
Mark Croxton

Hey Jon

if you’re doing that the most flexible approach is to use Low Search to filter entries by relationship.

Mark Croxton
# 4
Developer
Mark Croxton

Also, you may find this helpful if you’re using Playa and Taxonomy to simulate categories:

https://github.com/croxton/tax_playa

Jon Thomas
# 5
Jon Thomas

I just landed on his add-on page after some searching. Haven’t used that yet so thanks for confirming! I’ll give it a go.

Jon Thomas
# 6
Jon Thomas
Mark Croxton - 16 September 2014 11:55 AM

Also, you may find this helpful if you’re using Playa and Taxonomy to simulate categories:

https://github.com/croxton/tax_playa

Interesting. Does this only work with Playa? Or does it work with native relationships as well? I don’t have an issue using Playa, but if it supports relationships, it may save me the add-on costs.

Mark Croxton
# 7
Developer
Mark Croxton

Just Playa. Which is worth the money, IMHO.

Jon Thomas
# 8
Jon Thomas

Absolutely. Just wanted to make sure it was needed.

Here’s my scenario (tried to make it brief):

- Single landing page showing *sections* and *entries in those sections* Each *section* is a different channel.
- The URL Query has 3 params. Audience, Division, and State IE: audience=retail&division=01&state=IL
- Each one of these sections, and the entries within them need to display according to a match on those 3 params. Some entries could be “tagged” with multiple states, but it will only show if it has a match in the URL query. (Unless the entry is visible to *all* audiences, divisions, or states)
- I have yet to decide how my solution for “tag” or “categorizing the entries with matching data to the params. I started with 3 channels and was using relationships (baslically as categories) for each channel that needs to be able to segment its content. But I’m just using relationships to avoid duplicating the same custom fields on each channel, since everything needs to match all or some of these 3 params. I haven’t tried native categories yet. Scared to.

Does this still sound like a candidate for Low Search?

If there’s too much complexity there to answer to, I’d be happy to pay for some of your time to look at this in more detail and provide some direction. I’d like to avoid spending days testing various addons if someone can just learn my scenario in detail and make a recommendation.

Mark Croxton
# 9
Developer
Mark Croxton

Yes you can use Low Search to filter by one or more relationship fields, and you can pass multiple ids per field (separated by & for AND or | for OR logic).

If your filtering vectors need their own fields then entries related via Playa or native relationships are best. If they are simply ‘tags’ then plain old EE categories are fine too (‘States’ would be a good candidate for categories unless you plan on having a full page of content for each State). Low search works with playa, native relationships and categories. 

 

Jon Thomas
# 10
Jon Thomas

Great. Thanks so much for the responses. Very helpful. I’ll be sure to have Low send you your referral bonus as well. ;)

Jon Thomas
# 11
Jon Thomas

I’ve been digging into Low Search per your suggestion, but after sifting through the documentation, it seems to revolve around first submitting a form. When the page I’m talking about is loaded, it is loaded *with* the 3 parameters already in place. Do I need to trigger some sort of form submission first to create an encoded query before I can filter all the cannels with the Low Search results tag? Or is there some way to load a page with pre-defined URL parameters (no form submission) and filter my channel content?

If you know off-hand, great. If not, I’ll start a thread on some EE/Low Search support channels.

Mark Croxton
# 12
Developer
Mark Croxton

You can pass parameter values directly to the low_search:results or use an un-encoded query:
http://gotolow.com/addons/low-search/docs/settings#encode-query

If you pass parameters direct then you can use Stash to validate the expected values (since they are user input). E.g. assuming you have a playa or relationship field for ‘Audience’ set up for entries in the ‘divisions’ channel, and you pass /results?audience=123 as a query or /results/audience/123 (or via POST)

{exp:low_search:results 
  channel
="divisions"
  
child:audience="{exp:stash:get name="audience" dynamic='yes' match='#^[0-9]+$#'}"
  
parse="inward"
}
   {title}

{/exp:low_search} 
Jon Thomas
# 13
Jon Thomas

I see. Since the 3 URL parameters are the 3 relationship channels that I need to filter on for each content channel, would it be something like this? For instance, my news channel needs to show appropriate news entries for all 3 parameters.

{exp:low_search:results 
  channel
="news"
  
child:audience="{exp:stash:get name="audience" dynamic='yes' match='#^[0-9]+$#'}"
  
child:dc="{exp:stash:get name="dc" dynamic='yes' match='#^[0-9]+$#'}"
  
child:state="{exp:stash:get name="state" dynamic='yes' match='#^[0-9]+$#'}"
  
parse="inward"
}
   {title}

{/exp:low_search} 

I will defintely need to expand that to have some AND/OR logic since the user could technically choose to make an entry visible to “all” audiences, “all” states, but only a single “dc”.

And, since I have to use these values a handful of times, I suppose I could stash the GET parameters into easier-to-reference variables first.

{exp:stash:audience}{exp:stash:get name="audience" dynamic='yes' match='#^[0-9]+$#'}{/exp:stash:audience} 

Aside: The user is being redirected from another non-EE system with the pre-defined URL parameters, hence why I can’t rely on the form submission. Since my parameter values will likely come over as strings representing url_title instead of EE entry_ids, I suppose I would first have to find the entry_id for each URL parameter value before Low Search could do a relationship search on it. I thought I saw a convenient plugin for converting a url_title to an entry_id.

Mark Croxton
# 14
Developer
Mark Croxton

Yes three fields.You are progressively filtering entries with each filter applied (AND logic), so ALL states would simply mean passing an empty string to child:state. If you want to require either state 1 OR 5 then you would pass 1|5. If you want state 1 AND 5 then you would pass 1&5. You cannot however have an OR relationship for two different filters (e.g. state 1 OR dc 6).

You can do this to register the variable without outputting it:

{exp:stash:get name="audience" dynamic='yes' match='#^[0-9]+$#' output="no"

And then to use it in a parameter:

{exp:stash:audience} 

 

Jon Thomas
# 15
Jon Thomas

Great. And can I stash the audience, state, and dc variables for reference as the user moves through child pages of the site? Or best to keep the url query on every page? If the user logs out (takes them to the other system and logs them out), and log back in, I would just need to re-initialize those 3 stash variables.

I have been using session or cookie variables for that so far, but curious to know if stash can do that.

1 of 2
1