1

I tried to use all possible way for search but it doesn't work.

So what I have:

Channel countries:

  • field: country_name (like UK, USA, Ireland, Russia and etc)

Channel departments:

  • field: department_title (like tech, commerce, finance)

Channels careers:

  • field: title
  • field: careers_department_title(relationship with channel departments by field department_title)
  • field: career_role_location(relationship with channel countries by field country_name)

To display all from careers I do:

{exp:channel:entries channel="careers"}
  Job title - {title}
  Department title: {careers_department_title:department_title:}
  Role location: {career_role_location:country_name}
{/exp:channel:entries}

Now I need to do search by country or by departments.

{exp:low_search:filters query="USA"}
  {exp:channel:entries channel="careers" style="linear"}
   {career__country_name:country_name}
  {/exp:channel:entries}
{/exp:low_search:filters}

As result I have list of all countries, but I need only from specific country, in this example should be only USA, and no UK, Russia and other.

Can somebody advice how correctly to write this search by field which has relationship type?

My main goal to display dropdown menu and user can select search option: search by departments or by location.

Thanks in advance!

3

Couple of things here. I don't think you need the Preparse option as Jeremy suggested, as you can filter by country/department ID, not by their actual names. Here's what to do:

Results tag

Use something like this in your Results tag:

{exp:low_search:results channel="careers" query="{segment_3}"}
  code to display careers here
{/exp:low_search:results}

Make sure {segment_3} points to the encoded query in the URI. Something like query="USA" like you tried will not work.

Create a search form

In that form, you can let the user choose a country or department. Something like this:

{exp:low_search:form result_page="search/results"}

  <select name="child:the_country_relationship_field">
    <option value="">Select country</option>
    {exp:channel:entries channel="countries" dynamic="no"}
      <option value="{entry_id}">{country_name}</option>
    {/exp:channel:entries}
  </select>

  <select name="child:the_department_relationship_field">
    <option value="">Select department</option>
    {exp:channel:entries channel="departments" dynamic="no"}
      <option value="{entry_id}">{department_name}</option>
    {/exp:channel:entries}
  </select>

  <button type="submit">Search!</button>

{/exp:low_search:form}

Make sure that you replace the_country_relationship_field and the_department_relationship_field with their corresponding relationship field names.

This combination should give you the filtered results.

2
  • It works exactly what I need. Thank you very much! – Viktor Aug 29 '13 at 14:08
  • @Low How do i get search keywords in the result page when i do relationship search – user3553567 Apr 21 '14 at 7:36
1

The easiest method may be to use Solspace's free Preparse extension. It's a bit of a hidden gem. It essentially parses a template based on an entry id and stores it in a text field in the entry.

Low actually blogged about how to use Preparse with Low Search to make categories searchable. The same could be done for any fieldtype that doesn't use the standard exp_channel_data fields to store its data, such as a relationship or Playa field.

1
  • The main resean why I purchased low search is possibility to do search in fields with type: relationship. I cannot understand how links in your answer can help in my situation. – Viktor Aug 29 '13 at 13:35

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.