3

I have this search form in test/low-search-test

{exp:low_search:form collection="foo" secure="no" search_mode="all" result_page="test/low-search-test-results"}
<fieldset>
    <label>Job:</label>
    <select name="job" dir="ltr" id="job">
    {exp:low_options:job}
         {options}
            <option value="{option:value}">{option:label}</option>
        {/options}
    {/exp:low_options:job}
    </select>
</fieldset>
<button type="submit">Search</button>
{/exp:low_search:form}

and the results form in test/low-search-test-results

{exp:low_search:results}
  {if count ==  1}<ol>{/if}
    <li><a href="{comment_url_title_auto_path}">{title}</a></li>
  {if count == total_results}</ol>{/if}
  {if no_results}No search results{/if}
{/exp:low_search:results}

My problem is that the results page does not filter by job.It doesn't even respect the "collections" param in the search form. It returns all results including some channel entries not defined in the collections param.

Am I doing something wrong here? How do I filter results in Low Search based on their Channel Fields?

2

You need to add the query="" parameter to the Results tag so it knows what has been submitted.

Also, if you're searching a specific custom field, use the input name as though it was a parameter in the channel:entries tag. For example, this:

{exp:channel:entries channel="foo" search:some_field="bar"}

Would become this in a Low Search form:

<select name="search:some_field">
    <option value="foo">Foo</option>
</select>

So, in your case, you'd need to use name="search:job" in your select-element.

But all of that will be ignored anyway if you don't add the query="{segment_3}" parameter to the Results tag (where {segment_3} is the reference to the encoded query in the URI).

| improve this answer | |
  • Ok. Tested it and it now works! I was under the impression that it passes search form variables via $_POST and the query for hardcoded values so I removed it. Guess I was very wrong. – developarvin Jan 9 '13 at 8:21
  • Nope, in order to have bookmarkable/shareable search results, as well as pagination with search results, using only $_POST vars was not an option. The form does use POST, but the add-on catches the submission and encodes the data. It then puts the data in the URI, so the Results tag can get to it with the query="" parameter, which it then decodes. – Low Jan 9 '13 at 8:34

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.