0

In my search form I have this:

<input type="hidden" name="programs_courses_show_in_results" value="Yes">

And in the results I have this:

{exp:low_search:results 
  channel="programs_courses"
  entry_id="not 110"
  limit="100"
  query="{segment_4}"}

  {if count == 1}{total_results}{/if}

  {if count ==  1}<ol>{/if}

      <li><a href="#">{title}</a> <small>Count: {count} | Show: {programs_courses_show_in_results}</small></li>

  {if count == total_results}</ol>{/if}

  {if no_results}No search results{/if}

{/exp:low_search:results}

Technically, I also have some category parameters in the search form, but if I leave those alone and only hit the search button, the results show everything in the channel, not just the ones with the programs_courses_show_in_results field set to "Yes".

Am I missing something?

2

As per how parameters work, you need to prefix the var with low_search_.

Edited to elaborate:

The prefix is for outputting the parameter value as a variable. So, as shown in the docs, this:

<input type="hidden" name="param_name" value="param_value">

...results in the variable {low_search_param_name}. To translate that to your setup, having this in your form:

<input type="hidden" name="programs_courses_show_in_results" value="Yes">

...would mean {low_search_programs_courses_show_in_results} would output Yes.

However, you don't want just to output Yes. As I understand it now, programs_courses_show_in_results is actually a custom field that can contain the value Yes, so you want to filter search results and only display entries where that fields equals Yes, like you can with the native exp:channel:entries tag using the parameter search:programs_courses_show_in_results="Yes".

To achieve this in Low Search, use the Field Search filter, so you can either use that exact parameter on the exp:low_search:results tag, or use a (hidden) field in the Form tag, thusly:

<input type="hidden" name="search:programs_courses_show_in_results" value="Yes">

...which means you can output Yes using {low_search_search:programs_courses_show_in_results}

3
  • Yeah, I've read through the docs thoroughly and adding the prefix didn't change anything. I changed the hidden input to <input type="hidden" name="low_search_programs_courses_show_in_results" value="Yes"> and also tried <input type="hidden" name="{low_search_programs_courses_show_in_results}" value="Yes"> (which I know is wrong). The results page still shows all the entries in that channel, rather than just the ones with that field set to Yes. (It's a dropdown select field, if that matters). – Angie Herrera Oct 10 '15 at 15:27
  • Perhaps my edited post will clarify things. – Low Oct 10 '15 at 16:58
  • Ah, ok. That does work. Was about to switch to using a Status, but this works better. Thanks. – Angie Herrera Oct 10 '15 at 17:05

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.