3

I want to only search results from specific collection on specific search results pages.

My search results is basically like the Low Search Results example

{exp:low_search:results query="{segment_3}" limit="10"}
{if count ==  1}<ol>{/if}
<li><a href="{url_title_path="#"}">{title}</a></li>
{if count == total_results}</ol>{/if}
{if no_results}No search results{/if}
{/exp:low_search:results}

This shows me matching results from all saved collections. However, I only want to show results from a specific collection.

I see Low has the variable:

{collections}{/collections}

just not sure how to use it.

Thanks in advance.

1 Answer 1

2

If you are using a specific form to search for a single collection the best option would be to pass a hidden input in the search form

{exp:low_search:form}
 <input type="hidden" name="collection" value="collection_name">
 <input type="search" name="keywords" placeholder="Search">
 <input type="submit" value="submit">
{/exp:low_search:form}

You should also be able to do this on the results loop too but I haven't tested it. From your code above:

{exp:low_search:results query="{segment_3}" collection="collection_name_here" limit="10"}
  {if count ==  1}<ol>{/if}
    <li><a href="{url_title_path="#"}">{title}</a></li>
  {if count == total_results}</ol>{/if}
  {if no_results}No search results{/if}
{/exp:low_search:results}
3
  • thanks justin. that only worked if I put: collection="collection_name" in the results tag.
    – therooster
    Jun 12, 2014 at 1:59
  • I updated my code with another solution. Jun 12, 2014 at 2:21
  • 1
    The hidden input field that Justin suggested should work, too. If it doesn't, open up a ticket at my support page.
    – Low
    Jun 12, 2014 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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