Collection search doesn't work
Hi ! I tried to follow the instructions carefully, but couldn't make simplsearch work on page searches (global search works well).
Here's my code :
---
title: Blog
content:
items: @self.children
limit: 10
order:
by: date
dir: desc
pagination: true
url_taxonomy_filters: true
simplesearch:
route: @self
filters:
- @self
filter_combinator: and
---
...
When submitting the form, the query is correctly appended to the url, but the listing page shows all the items, just as if no query was set. Is it a bug ?
Perhaps have a look at @flaviocopes's reply to a similar question here.
I had a similar issue to the one you describe, with an almost identical page configuration to the example you give above.
I did as suggested in the answer, changing this line in my template to {% set collection = search_results ?: page.collection() %} and it fixed the issue for me (thanks flaviocopes).
Hope that helps.
@timrobbings Thanks that did the trick ! I think this should be fixed to work out of the box or specified in the doc
Another problem once this is solved is the inability to clear the search. If you enter an empty string, you can't submit the query. I think a link should be added to clear the search if there is a query. Here's my quick fix :
in templates/partials/simplesearch_searchbox.html.twig
...
{% if query %}
<a href="{{page.url}}">Clear the search</a>
{% endif %}
...
{% set collection = search_results ?: page.collection() %}
This should totally be added to the docs, this issue was driving me nuts