getgrav / grav-plugin-simplesearch

Grav SimpleSearch Plugin
https://getgrav.org
MIT License
44 stars 55 forks source link

No results are produced #183

Open asimakos opened 4 years ago

asimakos commented 4 years ago

I have integrated the search bar with glass button into my custom theme and applied the following config to /user/config/plugins/simplesearch.yaml:

enabled: true
built_in_css: true
built_in_js: true
display_button: true
min_query_length: 3
route: /search
search_content: rendered
template: simplesearch_results
filters:
  category:
    - '@none'
filter_combinator: and
ignore_accented_characters: false
order:
  by: date
  dir: desc

Unfortunately when i search for a keyword it routes to http://myserver/?searchfield=energy results page is not routed properly and additionally it gives no results. I have also added simplesearch_results.html.twig into templates folder and simplesearch_searchbox.html.twig into templates/partials folder. Additionally i have not created any category or taxonomy at all in my blog! Any idea what i am missing?

Regards

rascasse83 commented 4 years ago

same issue for me :-)

rascasse83 commented 4 years ago

I fixed my issue with search not working, when embedded in a page (it worked on its own, but not when the 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 :-)

rascasse83 commented 4 years ago

PS: replace "DXChange" in the URL with your website name

marcocevoli commented 4 years ago

same issue here

marcocevoli commented 4 years ago

All suggested doesn't work. Reverting back to version 1.1.2 works.

Grayches commented 2 months ago

Futher to the below, without gantry, just add the below line to the base.html.twig so the js loads: {% do assets.addJs('plugins://simplesearch/js/simplesearch.js', 98) %}

as below: {% block bottom %} {% do assets.addJs('theme://js/skel.min.js', 100) %} {% do assets.addJs('theme://js/main.js', 99) %} {% do assets.addJs('plugins://simplesearch/js/simplesearch.js', 98) %} {% do assets.addJs('theme://js/util.js') %} {{ assets.js() |raw}} {% endblock %}

I fixed my issue with search not working, when embedded in a page (it worked on its own, but not when the 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 :-)