Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search results path seems incorrect #149

Open
dcrobertson01 opened this issue Feb 21, 2018 · 5 comments
Open

search results path seems incorrect #149

dcrobertson01 opened this issue Feb 21, 2018 · 5 comments

Comments

@dcrobertson01
Copy link

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.

<form name="search" data-simplesearch-form="">
        <input name="searchfield" class="search-input" type="text" min="3" required="" placeholder="Search …" value="" data-search-invalid="Please add at least 3 characters" data-search-separator=":" data-search-input="/public_html/search/query">
                    <button type="submit" class="search-submit">
                <img src="/user/plugins/simplesearch/assets/search.svg">
            </button>
            </form>

Any help would be appreciated

@kenton-r
Copy link

you need to load the js.
{% do assets.addJs('plugins://simplesearch/js/simplesearch.js') %}

@Tiaryn
Copy link

Tiaryn commented Jul 20, 2018

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.

@kenton-r
Copy link

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>

@surdacz
Copy link

surdacz commented Jan 15, 2019

Putting line to do assets does not help me. Only function variant for me is to have script and input field together:

<script src="/grav/user/plugins/simplesearch/js/simplesearch.js"></script>

{% include 'partials/taxonomylist.html.twig' with {base_url: '/blog', taxonomy: 'tag'} %}

@rascasse83
Copy link

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

<script src="/DxChange/user/plugins/simplesearch/js/simplesearch.js"></script>

Subsequently the search works ! Et voila :-)

PS: replace "DXChange" with your website name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants