2

I'm working on a search section of a site which allows users to find a list of shops based on their categories.

I would also like to find shops that have offers.

Offer entries have a relationship field which links it back to the shop entry.

With Low Search, is it possible to run this psuedo code?

Give me all of the shops from category 2 that are a parent to an open offer

2
+200

There are two filters in play here, especially if you slightly re-phrase your last sentence:

Give me all of the shops from category 2 and that are a parent to an open offer

First of all, you need the Categories filter. And because you're just after a single category, you can use the native category="" parameter.

Secondly, you need the Relationships filter for the second half. This is slightly trickier. The Relationships filter, like the Categories filter, accepts IDs. With the Categories filter, you're selecting which category to filter by; with the Relationships filter, you're selecting entries rather than categories.

However in your case, you're not selecting entries. You're after a pre-defined list of entries: "open offers". So, what you're really after is a way to populate the Relationships parameter with a pipe-separated list of entry_ids: the open offers.

Also note: you're saying "a parent to an open offer", but they way you described the relationship, an offer is a parent to a shop:

Offer entries have a relationship field which links it back to the shop entry.

For the Relationships filter, you therefore need to define the parent:field_name parameter, where the field_name is the Relationship field in the Offers channel, and the parameter contains Offer entry IDs.

As a parameter string, it would look something like this:

{exp:low_search:results channel="shop" category="2" parent:field_name="1|2|3"}

...where field_name should be replaced with the actual relationship field name, and 1|2|3 is the pipe separated list of "open offer" entry IDs.

| improve this answer | |
  • Brilliant - that worked like a charm. Thanks for the help Low. I have built a basic plugin at github.com/andrewfairlie/rc_open_entries that returns the entry_ids for offers for me and may be of use to others. – Mutual Jul 21 '14 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.