Can I load low search results into a dynamic page without getting a 404?
I have a page that shows entries with the same category url title as the page url title. I am adding a search and would like the search results to show on the same page. When I return to the page with the search query encoded in the URL it sends me to the 404 template. Do I need to do this with an AJAX call to maintain the page?
Replies
Low 26 Oct 2017 18:48
404's aren't necessarily triggered by Low Search. Perhaps the 404 is triggered by something else, like Structure (if installed). Can you elaborate on what your situation is, along with example templates? You can use http://pastie.org/ or http://pastebin.com/ for large chunks of code.
Kari-Lyn Henkel 26 Oct 2017 20:36
I have included the page template below.
Each page is connected to a category. These categories contain listings that the client would like site visitors to be able to search within the category page. So the search results should show up on the same page that is being searched, however, the encoded URL triggers the redirect to the 404.
https://pastebin.com/enWifebr
Low 27 Oct 2017 10:37
I can see several things that could be improved with that template. For example:
url_title="segment_2"
should beurl_title="{segment_2}"
Also, nesting the low_search:results tag inside the channel:entries tag will give you unexpected results, as the variables inside the low_search:results tag will be parsed by the outer channel:entries tag. You might need to work around that using an embed.
As for the 404; Low Search doesn't trigger it. Looks like you're using Structure, which could mean that that causes it.
If a URI like /foo/category returns an entry, but /foo/category/query returns a 404, then you should look at the logic of your template as well as Structure's configuration with handling (strict) URLs. There's nothing in the template that suggests that LS is triggering the 404.
Kari-Lyn Henkel 27 Oct 2017 12:09
I'm seeing several errors in the template myself, sorry about that must be getting tired. This points me in the right directions, thank you.