How to search based of the segment_url
How can I perform a search, based of the segment url? What I'd like to accomplish is a structure like this:
/search/baseball+games
Where /search will contain my results template, and segment 2 is the search keywords?
If that is not possible, I've been looking at the docs, and I should be able to search with the encoded option turned off, in which my get params looks like the following:
/lowsearch?collection=all&search_mode=any&keywords=vanilla
How do I structure my search results template? The following which is from the docs, doesn't work:
{exp:low_search:results query="{segment_3}" limit="10"}
{if count == 1}
- {/if}
- {title}
{if count == total_results}
{if no_results}No search results{/if}
{/exp:low_search:results}
Replies
Low 29 Apr 2013 16:21
If you're not encoding the query in the URL, don't add the query="" parameter to any of your tags. Then it should work. The URL structure you mention (in the beginning) is not possible, as the query contains more than just keywords.
James Lukensow 29 Apr 2013 16:24
Okay, so I end up with a query that looks like the following:
/lowsearch?collection=all&search_mode=any&keywords=vanilla
But, even if I don't add any keywords, the results page always displays the same resutls, with or without the keywords tag. I change the keywords, but they're always the same results.
{exp:low_search:results limit="10"}
{if count == 1}
{/if}
- {title}
{/if}{if count == total_results}
{if no_results}No search results{/if}
{/exp:low_search:results}
Low 29 Apr 2013 16:28
As explained in the docs, not all servers support GET vars in combination with EE. If this is not working for you at the moment, you'd have to use the encoded query in the URI (and the query="" param). That would mean you can't see the readable keywords in the URL, I'm afraid.
James Lukensow 29 Apr 2013 16:31
Ahh, Okay. Let's say we go the encoded route, if we need to manually encode the url (since the request is coming from the front end, javascript), is it the entire query string that's getting encoded?
Low 29 Apr 2013 16:55
If you're using JS, then use JS to submit the Low Search Form. Check out this example: https://gist.github.com/lodewijk/4632695
James Lukensow 29 Apr 2013 21:11
Thanks!
If we go the route of the urlencoded form, i assume we still have to build that functionality correct?
Low 30 Apr 2013 08:25
Yes, just follow the docs and use the query="" parameter where appropriate.
Sulok Jha 7 Jan 2014 11:28
I am using
{exp:low_search:results query="{segment_3}" limit="10"}
{if count == 1}
{/if}
{title}
{if count == total_results}
{/if}
{if no_results}No search results{/if}
{/exp:low_search:results}
always getting "No search results"
In {segment_3} query cumming in encoded properly.
I am not understanding what is the issue.