Open dcrobertson01 opened 6 years ago
you need to load the js. {% do assets.addJs('plugins://simplesearch/js/simplesearch.js') %}
Where do I need to load the js? It does not work when I just create a search page and write this
{% do assets.addJs('plugins://simplesearch/js/simplesearch.js') %}
{% include 'partials/simplesearch_searchbox.html.twig' %}
and I don't want to load it inside the base file because I only want to load it when I need it.
Why is this not mentioned in the documentation? Including the js file seems mandatory for the plugin to work. Why is this not mentions in the doc? I have got the feeling I'm missing something obvious.
The JS controls the search form. so any where you have the search bar you need the JS. I have not searched to find out why it does not loading from the plugin. (line 300 in simplesearch.php). but I loaded it in my "base.html.twig" file in the assets block.
{% block javascripts %}
{% do assets.addJs('theme://bower_components/jquery/dist/jquery.min.js') %}
{% do assets.addJs('theme://bower_components/what-input/what-input.min.js') %}
{% do assets.addJs('theme://bower_components/foundation-sites/dist/js/foundation.min.js') %}
{% do assets.addJs('plugins://simplesearch/js/simplesearch.js') %}
{% do assets.addJs('theme://dist/scripts/main.min.js') %}
{% endblock %}
{{ assets.js() }}
</body>
</html>
Putting line to do assets does not help me. Only function variant for me is to have script and input field together:
{% include 'partials/taxonomylist.html.twig' with {base_url: '/blog', taxonomy: 'tag'} %}
I had the same issue
I fixed my issue with search not working, when embedded in a page (it worked on its own, but not when the search form was embedded in a page).
Bear in mind my fix applies to the Gantry5 Framework & Hydrogen theme, but it might work for you.
The issue was that the Javascript was not loading.
I change the page.html.twig template to include this piece of code on line 65
{%- do gantry.document.addScript(url('/DxChange/user/plugins/simplesearch/js/simplesearch.js'), 11, 'footer') -%}
This results in the javascript being loaded in the HTML (check the code source) near the footer
Subsequently the search works ! Et voila :-)
PS: replace "DXChange" with your website name
Greetings, When I search I get no results. If I am on a page /this/page, and I use the search box, I get this page
https://server/this/page?searchfield=minim+veniam
and no results.
If I go to /search and search from there, I get this page
`https://server/search?searchfield=minim+veniam'
and no results.
If I enter
https:/server/search/query:minim veniam
I get a page with some results on it.I don't see where this path is set. I see it in the javascript file - and appears to be set on the form correctly.
Any help would be appreciated