grav-plugin-simplesearch icon indicating copy to clipboard operation
grav-plugin-simplesearch copied to clipboard

Simple can't access result page

Open cboehm-it opened this issue 7 years ago • 12 comments

Hello,

I hope you can help me. I don't have an idea why it's not working.

At my blog site I has a simple search box. http://cboehm.it/blog Category is set to blog.

After press Enter the blog site will be reload but no search result appears. What could be wrong?

Thank you

cboehm-it avatar Sep 30 '17 07:09 cboehm-it

Same :)

myrsk avatar Oct 17 '17 05:10 myrsk

I have the same problem. I noticed that on my non-working installation, whenever I search for something, there is ?searchfield= added at the end of the URL and not /search/query: as per the documentation.

ghost avatar Oct 25 '17 04:10 ghost

Hey folks,

I had the same Issue and had a look on the forums. That is, where I found a solution. As it seems, simplesearch doesn't include the JS-file (on some themes), so that you have to add it on your own.

For more info check out this forum post: https://discourse.getgrav.org

After I added the JS-file to the footer of my site, the search started working again.

Hope that did help you!

Heartfyre avatar Oct 30 '17 14:10 Heartfyre

I think we need to run through all the core team's Grav themes and add this empty bottom block to them all. We didn't have the ability of having multiple JS blocks when we wrote most of the themes originally.

rhukster avatar Oct 31 '17 00:10 rhukster

As @Heartfyre said, the Javascript file /user/plugins/simplesearch/js/simplesearch.js may not be loaded.

Solution: Find the file where the HTML code for the SimpleSearch plugin is loaded. For the afterburner2 theme, the file is user/themes/afterburner2/templates/partials/sidebar.html.twig.

You will see these lines:

{% if config.plugins.simplesearch.enabled %}
    // HTML code
{% endif %}

In this block, and after the HTML code, insert the Javascript file:

{% if config.plugins.simplesearch.enabled %}
    // HTML code
    <script src="/user/plugins/simplesearch/js/simplesearch.js" type="text/javascript" ></script>
{% endif %}

Then it should work properly.

dtrecherel avatar Nov 01 '17 10:11 dtrecherel

@dtrecherel Did this, problem not fixed. http://voidmain.xyz still showing up ?searchfield. Also, if i was at http://voidmain.xyz/blog , input something to the searchbox, i get this http://voidmain.xyz/blog?searchfield=dwdw not xxx.com/search/query:xxx . Basic the same question.

liqimore avatar Dec 22 '17 16:12 liqimore

@liqimore and @dtrecherel Adding this line to base.html.twig before the tag </body> works. <script src="/user/plugins/simplesearch/js/simplesearch.js" type="text/javascript" ></script>

But now there is the next problem. I search for an query at cboehm.it/blog/. The search result appears at route /blog/search but without any result. (I define this route in the config)

The search only works if I try a query at a higher page. https://cboehm.it/search/query:Leipzig

Whats wrong? There are no more config files...

cboehm-it avatar Dec 28 '17 22:12 cboehm-it

I have experienced the same problems as above using the Anitmatter theme with Simplesearch installed.

The default configuration has Category filter default to Blog. I want Simplesearch to search my entire site, so, I cleared the Category filter field, in the Admin interface, so Simplesearch would search my entire site and not be limited to searching just Blog.

What I have found is, when clearing the Category filter field in the Admin interface, it deletes the entire Category filter keys and value (Blog) in the config file rather than just deleting the value (Blog). This renders Simplesearch inoperable.

To fix this I put the Category filter keys back into the config file, manually, and left the value blank. Simplesearch then works perfectly.

pbatts avatar Jan 06 '18 03:01 pbatts

Any update on this? Tried all workarounds suggested in the thread, none of them successful.

However, I seemingly managed to get things working by updating /user/plugins/simplesearch/templates/partials/simplesearch_searchbox.html.twig.

From:

<form name="search" data-simplesearch-form>
    <input
        name="searchfield"

To:

<form name="search" data-simplesearch-form action="search">
    <input
        name="query"

This changes the query into something that grav seems to understand (/search?query=xxxxx).

Concerning that this plugin seems somewhat broken out of the box.

AugustGSP avatar Jan 12 '18 22:01 AugustGSP

@AugustGSP You made my day. Now it works.

cboehm-it avatar Feb 11 '18 17:02 cboehm-it

@AugustGSP Also worked for me. Thank you so much August. Spent 3+ hours trying to fix this. This needs to be fixed in the base install!

jshflwrs avatar May 21 '18 05:05 jshflwrs

Found a problem with this technique though, it 404s when you try and activate the search from any subdirectory, because it tries to append /search from the current page. EG: domain.com/sudirectory/search

jshflwrs avatar May 21 '18 05:05 jshflwrs