getgrav / grav-plugin-simplesearch

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

simplesearch search results page (route? problem) #138

Open calvez opened 6 years ago

calvez commented 6 years ago

Hello!

I'm just not able to make it work. :( Grav and simple search are the latest version, the simplesearch.yaml is here:

enabled: true
built_in_css: true
display_button: false
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

you can check the site here

search queries looks this way

And if you include the /search as the config suggest it's ok: check

I already tried evey suggestion. The js is loaded, the index is ok, the results are perfect....

Searchbox looks like this:

                <div class="searchbox">
                    <label for="search-by"><i class="fa fa-search"></i></label>
                        {% include 'partials/simplesearch_searchbox.html.twig' %}
                    <span data-search-clear><i class="fa fa-close"></i></span>
                </div>

The searchbox twig is basically the same as original:

        <input
            name="query"
            class="search-input"
            type="text"
            {% if min_chars > 0 %} min="{{- min_chars -}}" {% endif %}
            required
            placeholder="{{"PLUGIN_SIMPLESEARCH.SEARCH_PLACEHOLDER"|t}}"
            value="{{ query }}"
            data-search-invalid="{{ "PLUGIN_SIMPLESEARCH.SEARCH_FIELD_MINIMUM_CHARACTERS"|t(min_chars)|raw }}"
            data-search-separator="{{ config.system.param_sep }}"
            data-search-input="{{ base_url }}{{ config.plugins.simplesearch.route == '@self' ? '' : (config.plugins.simplesearch.route == '/' ? '' : config.plugins.simplesearch.route) }}"
        />
rhukster commented 6 years ago

The learn skeleton has a special overriden version of the search box that makes an ajax call via simplesearch and then uses the json response to filer the sidebar for appropriate topics (see the learn.getgrav.org site).

You can use the search landing page and it works if you go here: https://tozsdeabc.bet.hu/search?query=index but the search box is not intentionally targeting that.

You could add a link to 'advanced search' like we do on learn.getgrav.org, and that goes to a dedicated landing page, however note that we've swapped out simplesearch for tntsearch plugin now as it's much more powerful and is faster when there is more content.

ghost commented 6 years ago

Is it possible to make it select-able if one wants to use simplesearch or tntsearch under /search? I tried to get simplesearch working (search query is entered wrong in url - not working) under /search but couldn't it get to work. Changing code is not a good thing I think, as it might be overwritten in future.

woosting commented 6 years ago

FYI (might be a temporary workaround for you if you do the same):

I thought my pull-request (156) fixed the simple search results when used via .../search, but it got reverted as it broke other things apparently (so inform yourself about that).

And yes, updates will revert your change should you make it.

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