getgrav / grav-plugin-simplesearch Goto Github PK
View Code? Open in Web Editor NEWGrav SimpleSearch Plugin
Home Page: https://getgrav.org
License: MIT License
Grav SimpleSearch Plugin
Home Page: https://getgrav.org
License: MIT License
using default template and calling inside the page
/search/query: works fine but the actual search bar does not respond. its like submit doesnt actually get called
simplesearch.yaml:
enabled: true
built_in_css: true
display_button: true
min_query_length: 3
route: /search
template: simplesearch_results
filters:
Hey guys!
I am wondering what I may be doing wrong here. I am adding simplesearch to an existing pre-planned search input that I have in a partial for my theme. I am getting the below error:
"Unexpected character "&" in "@page:/user/plugins/error/pages" at line 1."
I attached the searchbox partial which I customized to match my theme and the template I customized and added to my theme:
simplesearch_results.txt
simplesearch_searchbox.txt
I am curious if this is a bug or perhaps I have overlooked something in the documentation. It appears that all of the simplesearch yaml files exist and are in the plugins directory where they should be, and match up with the documentation.
Any help would be greatly appreciated!
The plugin SimpleSearch can't be configured using the Admin Panel. For example, if we go to the settings page of the plugin (url /admin/plugins/simplesearch
) and click on Save, there's the following error:
Validation failed: order is not defined in blueprints
My config: Grav v0.9.39, Admin Panel v0.4.2, SimpleSearch v1.4.0
Right now, the search returns ALL pages by default - even the unpublished ones. How can we limit this to return only published ones?
I have created a manual with Grav which first started german-only. It all worked fine with the simple search and I never got an error. But as Switzerland is multi language, I needed to implement the whole content in french. So I used the powerful multi language ability of Grav and with the content it all worked fine as expected. But when entering the first search term, I was a little bit confused. I always got an Crickey! - Error on some but not all search terms. But more confusing was, that I can't see any logical sense, which terms are causing an error and which ones are not.
Because the standard search form which is provided with simple search doesn't work for me (enter doesn't search) I decided to create my own input field.
If you enter a search term like "Auto" it will give a Error. (path/de/search/query:auto
)
If you enter a search term like "Soldat" it will show up the results. (path/de/search/query:soldat
)
I tried to use my user
- folder on a clean installation - it gave me the same error. Also on a webspace instead of locally on MAMP (tested on two Macs) the problem appears.
Because I'm in apprentiship and my supervisor wanted to show me Git, my project is on GitHub, so you can recreate it:
Link to GitHub Repo (dev)
When searching a minor umlaut no capital umlaut is found by simplesearch (and reverse).
Right now, when a string is found, only the 'page route' is stored. It would be handy to also return a an array of text 'around' the string to use in a summary of results.
Server worked on IIS 8.5 on Windows Server2012 R2 with russian translation.
All russian translated operation system are working on cp1251 encoding.
/** @var Uri $uri */
$uri = $this->grav['uri'];
$query = $uri->param('query') ?: $uri->query('query');
$route = $this->config->get('plugins.simplesearch.route');
$query = iconv('cp1251', 'utf-8', $query);//patch
Patch $query convertation can resolve this problem, but it's wrong way to solution and i do not sense how it shell be done.
Grav have no problem with opening files wich content is utf-8 encoding, have no problem with filenames with cp1251 encoding, but russian symbols in URL reed not correctly.
Regarding clean URL i mean use only eng charachters is true, but for this plugin URL can contant anything.
Grav allows taxonomy terms to contain forward slashes.
For example, the AC/DC
in:
title: Back in Black
taxonomy:
genre: Rock
artist: AC/DC
---
However, when processing a search query that contains a forward slash, Grav displays an Error 404 page. For example:
Here is the URL of that page on the Grav Blog Skeleton demo site:
https://demo.getgrav.org/blog-skeleton/search/query:AC/DC
For comparison, when processing a search query that does not contain a forward slash (but still doesn't match any pages), Grav displays a "found 0 results" page. For example:
Here is the URL of that page on the Grav Blog Skeleton demo site:
https://demo.getgrav.org/blog-skeleton/search/query:ACDC
Tested both on newest Safari and Chrome - in both cases I cannot trigger search by pressing "Enter" inside search field.
UPDATE: I know why is this happening - it's because it's calling jQuery that it's not there yet - I am adding all JS at the bottom of each page and this script is trying to execute something earlier. How can I append the JS for search after all other assets?
I would like to set up a self-controlled search page where the search route is the route of the page itself. I want to do that:
my_page_frontmatter
---
simplesearch:
route: '@self'
filters: '@self'
filter_combinator: and
content:
items: '@self.descendants'
Problem is, it seems I can only define absolute routes overrides.
Hi,
you read in query parameter.
You use query value unfiltered.
You put query parameter unfiltered in twig variables.
You use the variable as it is in the twig templates.
I hope this is an exceptional case and the rest of the code is more safe?!
Thx
Hey guys,
Is multilang supported by SimpleSearch? I have had problems to set it up, creating /en or /fr directories under the template directory do not seem to work (problems with paths...).
Would it be possible to have a working example ?
Thanks for your time,
ArnCo
Hello there,
I am very new to Grav, have a bit of experience with Twig and PHP. I installed SimpleSearch as well as the breadcrumbs plugin and wondered if there was an (easy) way to integrate those two, I might otherwise get into the code and go for an "ugly" fix but it might be something great to implement !
Anyway, here are the facts: the breadcrumbs works fine with all the pages but the search pages. There is no breadcrumb. I wonder if the SimpleSearch plugin could expose a path similar to those being parsed by breadcrumb ?
A few examples:
Browsing normal stuff -- default breadcrumbs behaviour, not related to search.
Home > Products > Web > Documentation > API Endpoints
Search without restricted directory
Ex: looking for "Help"
Home > Search: "Help"
Search with a restricted directory, ex: route: Home/Products/Web
Home > Products > Web > Search: "Help"
I hope I was clear, my english is perfectible !
Anyways thank you for such an awesome plugin !
BTW This is a suggestion, not an issue 😄
I placed a searched box, via {% include 'partials/simplesearch_searchbox.html.twig' %}, in my header template. If I'm on the /search page and try to search for a new query from the search box on the page, not in the header, it will use the value from the search box in the header instead.
Thanks!
If I force https (which is what the site should be) then searching no longer works. I am getting this error on searches in FireFox :
The address wasn’t understood
Firefox doesn’t know how to open this address, because one of the following protocols (undefined) isn’t associated with any program or is not allowed in this context.
You might need to install other software to open this address.
The url in the browser when this happens shows undefined:undefined
as the address.
What is the deal here and how can I fix this? I am assuming somewhere it is trying to use http or something, but I could be wrong.
Error occurs only with language setting not left blank (examples used: en-US, fr-FR…) in the Admin:
Settings > Language > Supported (first field)
An exception has been thrown during the rendering of a template ("Invalid argument supplied for foreach()") in "simplesearch_results.html.twig" at line 12.
Open: /srv/data/web/vhosts/domain.tld/htdocs/vendor/twig/twig/lib/Twig/Templ ate.php
if (false === $e->getTemplateLine()) {
$e->setTemplateLine(-1);
$e->guess();
}
throw $e;
} catch (Exception $e) {
throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getTemplateName(), $e);
}
} elseif (false !== $parent = $this->getParent($context)) {
If I set "Translations Enabled" to "No" and try to search for something, grav throws an exception. Similiar stacktrace and problem as #13:
An exception has been thrown during the rendering of a template ("Invalid argument supplied for foreach()") in "simplesearch_results.html.twig" at line 15.
Using search version v1.9.3 and newest grav (v1.1.9)
Hi. My question is if it is possible to limit the search only to the article names? I've read that by default the plugin is searching for strings in both header and content but that delivers a lot of false results in my case. I've found no option in the config of the plugin.
Thanks in advance.
When using this plugin, after inputting a search term and getting the results, if I click one of the langswitcher links, it keeps the params in the URL, but strips /search
, so all I get is a polluted home page URL. See gif.
Ideally, when switching language from the search page, the URL should go to the pure home page of the selected langauge (since the search only searches in the given language anyway, and the term I searched for becomes useless after a lang switch).
Hi,
When using the admin plugin, when I remove the only tag in the Category filter
, the line filters:
is deleted from simplesearch.yaml
.
When this line is not present, the search fail even when there are result.
After adding the line filters:
manually, the search works again.
And when editing another field in the admin plugin, the line is removed again.
Hi, it doesn't work "research" on my site
http://www.michelepalmieri.it/www/faicchio/rassegna-stampa
I have a site structured in this way
rassegna-stampa/2015/ (blog)
rassegna-stampa/2015/Gen (blog)
rassegna-stampa/2015/Gen/page-01 (item)
rassegna-stampa/2015/Gen/page-02 (item)
rassegna-stampa/2015/Gen/page-03 (item)
rassegna-stampa/2015/Gen/page-04 (item)
....
....
....
rassegna-stampa/2016/ (blog)
rassegna-stampa/2016/Gen (blog)
rassegna-stampa/2016/Gen/page-01 (item)
rassegna-stampa/2016/Gen/page-02 (item)
rassegna-stampa/2016/Gen/page-03 (item)
rassegna-stampa/2016/Gen/page-04 (item
When I search for a string consisting of only spaces, by entering those spaces (encoded as %20
s) directly into the address bar, the Grav Blog Skeleton demo site shows a "Server Error" page. This is shown in the Experiment C section below.
Experiment A. Search for non-whitespace characters, using search form:
I get a "0 results" message. I consider this to be the "by design" behavior.
Link: https://demo.getgrav.org/blog-skeleton/search/query:test
Experiment B. Search for whitespace characters only (i.e. 4 spaces, entered as
), using search form:
I get an "Error 404" page.
Link: https://demo.getgrav.org/blog-skeleton/search/query:
Experiment C: Search for whitespace characters only (i.e. 4 spaces, encoded as %20%20%20%20
), using address bar:
I get a "Server Error" page containing information about the PHP code in use.
Link: https://demo.getgrav.org/blog-skeleton/search/query:%20%20%20%20
In /user/config/plugins/simplesearch.yaml I set filters: []
and I get different results from if I set filters:
filters:
appears to get correct results
filters: []
usually produces no results, but sometimes seems to work with a filter setting I used earlier. Eg I set filters: [ England ]
and it works, then change it to filters: []
and I may get the same result.
As far as I can see the page title comes from "pages/simplesearch.md". Have I overlooked something or does that mean the page title is not able to be multilanguage?
Hi,
It seems that when searching for a specific word in Romanian we have a small issue.
When the official and traditional language is used with words containing șțâăî in the title and articles, a search without this characters will be null and wont find anyting.
Is there a way that the characters mentioned above could be changed to their representation without the * special , etc ...* while doing the search ? as an example:
title of article is : Cum să înțelegem gramatica. when searching for "Cum sa intelegem gramatica" the result is nowhere due to the different characters (of course).
If when introducing the normal characters there could be a transformation of either the "article title" or the "text introduced" to be grammatically correct then a proper result will occur.
Not sure which is easier or even possible to do considering the Romanian language is not hugely spoken over the world and it seems that not even popular with Developers (Google, Microsoft, Apple, Adobe ... since it took them almost 30 years to implement the special characters, not to mention the translation which is not there yet).
Just a thought - could this be a valid thin in French, Spanish etc .. ? replacing the characters with the proper ones containing " ș ț â ă î a à á â" etc ... ?
I don't know what details you might need to reproduce this, but basically what I'm trying to do is to add a simplesearch configuration to a collection page, to be able to query its children. I'm using this page frontmatter:
---
title: Projects
simplesearch:
route: @self
filter_combinator: and
filters:
- @self
content:
items: '@self.children'
---
And I'm getting this exception:
Whoops\Exception\ErrorException thrown with message "Indirect modification of overloaded property Grav\Common\Data\Data::$route has no effect"
Stacktrace:
#15 Whoops\Exception\ErrorException in /vagrant/grav-admin/vendor/rockettheme/toolbox/ArrayTraits/src/NestedArrayAccess.php:64
#14 Whoops\Run:handleError in /vagrant/grav-admin/vendor/rockettheme/toolbox/ArrayTraits/src/NestedArrayAccess.php:64
#13 Grav\Common\Data\Data:set in /vagrant/grav-admin/user/plugins/simplesearch/simplesearch.php:103
#12 Grav\Plugin\SimplesearchPlugin:onPagesInitialized in /vagrant/grav-admin/vendor/symfony/event-dispatcher/EventDispatcher.php:184
#11 call_user_func in /vagrant/grav-admin/vendor/symfony/event-dispatcher/EventDispatcher.php:184
#10 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in /vagrant/grav-admin/vendor/symfony/event-dispatcher/EventDispatcher.php:46
#9 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in /vagrant/grav-admin/vendor/rockettheme/toolbox/Event/src/EventDispatcher.php:23
#8 RocketTheme\Toolbox\Event\EventDispatcher:dispatch in /vagrant/grav-admin/system/src/Grav/Common/Grav.php:272
#7 Grav\Common\Grav:fireEvent in /vagrant/grav-admin/system/src/Grav/Common/Processors/PagesProcessor.php:25
#6 Grav\Common\Processors\PagesProcessor:process in /vagrant/grav-admin/system/src/Grav/Common/Grav.php:121
#5 Grav\Common\Grav:Grav\Common\{closure} in /vagrant/grav-admin/system/src/Grav/Common/Grav.php:358
#4 Grav\Common\Grav:Grav\Common\{closure} in /vagrant/grav-admin/system/src/Grav/Common/Grav.php:334
#3 call_user_func_array in /vagrant/grav-admin/system/src/Grav/Common/Grav.php:334
#2 Grav\Common\Grav:__call in /vagrant/grav-admin/system/src/Grav/Common/Grav.php:122
#1 Grav\Common\Grav:measureTime in /vagrant/grav-admin/system/src/Grav/Common/Grav.php:122
#0 Grav\Common\Grav:process in /vagrant/grav-admin/index.php:45
But if I change the route
property on row 3 to read route: /projects
(which is the actual URL of the page itself), it works fine.
I'm using the latest version of simplesearch, with the default configuration.
Hallo, I have the strange behaviour, that the search plugin cant find any word. Everything else works in Grav.
Any idea?
Maybe useful. Thanks for the nice plugin!
Javascript (JQuery)
$(document).ready(function() {
$('#search-form').submit( function() {
searchKeyword = '{{ base_url_absolute }}/search/query:' + $('#keyword').val().toLowerCase();
window.location = searchKeyword;
return false; // Prevent the default form behaviour
});
});
HTML
<form id="search-form">
<input type="text" id="keyword" />
</form>
Is there a opportunity to make the search request happen when the user presses an button? Would be great! Please help me out on this one.
Greetss Bas.
It doesn't look like SimpleSearch is allowing query by keyword.
It looks like it's attempting to find pages by taxonomies but I feel that this line is taking out the pages that would be found by taxonomy.
To confirm, if you browse by category you can find posts but when you search by that category it doesn't find any results.
Cheers!
Hello,
I tried to install simplesearch on a fresh grav install. Il only have one page which is the default homepage installed with the antimatter theme.
I tried to remove the
filters:
category:
- blog
part in order to search all the pages (the only page, actually) but I can't make it work. I tried some simple queries such as skeleton
or page
but the search result is always empty (0 results).
Did I missed something important ?
When the Category filter is set to an empty string by the grav admin panel, the search result never returns a result.
I investigated the problem and found that the check for empty filter here is always false.
I think the cause is, that the $filters var is never empty it is a map containing {category: null}. I'm very new to grav and php in general, but thing it is due to the blueprint definition.
i made a pull request that fixes the problem for me, but I'm not sure if it's done the "right" way.
php: 5.6.15
grav: 1.0.10
SimpleSearch: 1.6.2
More of a question - the content from my site is mostly in modular pages. Searching matches the appropriate parent page, but the content is empty because the parent's content is non-existent.
I was able to work around this by commenting out this block so that modular pages are included in the results.
I modified my search result loop to display the parent page name but the modular page content.
Is there a better way to include the modular page's content in search results?
throw new \RuntimeException('Page Not Found', 404); Exception-Search is not working with custom taxonomy..
have a listing page called instructors and several item with name instructor. I want to add search functionality to this listing page like a blog page, but there is error coming each time i search any item ..
i also checked directly by entering url http://localhost/abc/instructors/search/query:ada but same error.
I have added category : -instructors to head of instructors.md file..
kindly help
Trying to get a search dropdown to work, how can I access the json twig template? Would this have to be by a route?
I'm trying to set up a per-page search feature as described here, however when searching the template simply renders the same page, instead of filtering content by the search query.
Steps to reproduce:
Download and extract the blog site skeleton. I'm using PHP's built-in webserver for testing, but I've also tried Apache with identical results.
Edit the file user/pages/01.blog/blog.md
and append the following to its frontmatter:
simplesearch:
route: /blog
filters:
- /blog
- @taxonomy: [tag]
filter_combinator: and
Open the site in a browser and attempt searching. Searching will redirect the page to /blog/query: as expected, but then will load exactly the same page again, without filtering by the search query.
Did I miss a step when setting up simplesearch?
SimpleSearch doesn't find results because of html tags in page content.
For example we have a page with the following markdown content:
## Grav **is** _awesome_!
Then if we try to search grav is awesome
, there will be no results because $cpage->content()
returns:
<h2>Grav <strong>is</strong> <em>awesome</em>!</h2>
But if we strip tags from content, e.g. strip_tags($cpage->content())
the query string grav is awesome
will be found.
Hi. I've implemented simple search into my online magazine. In the config I've set the hierarchy to look for the "content title" - sadly, it doesn't seem to accept this properly as the first results don't match my search term or the title of the article. You can see this by checking out: https://mnmz.de/mdrnhf and by using the search function in the upper right.
Also I would like to know why you think the search takes so long. There are approx. 650 articles in the system - is this the problem and are there any ways to speed this up?
Thanks in advance
I've installed the latest GRAV + Admin + simplesearch and added the form in my blog sidebar. The blog ist routed under /blog and is not the home directory, so the search submit was routing to it every time and no result page was shown. After I changed the {{ base_url }} to {{ base_url_absolute }} in the search box template, the result page is shown, but without any results. I tried to let everything default, but it did not work.
site where the error can we shown: http://dev.influxe-gaming.de/blog
simplesearch.conf:
enabled: true
built_in_css: false
display_button: false
min_query_length: 2
route: /suche
template: results.search
filters:
category:
- blog
filter_combinator: and
order:
by: date
dir: desc
sidebar include:
{% if config.plugins.simplesearch.enabled and page.header.sidebar.simplesearch.enabled %}
<widget class="search" style="order:{{ page.header.sidebar.simplesearch.order }}">
{% include 'partials/box.search.html.twig' %}
</widget>
{% endif %}
box.search.html.twig: http://hastebin.com/uvuketufuw.bash
results.search.html.twig: http://hastebin.com/bilopegone.scala
I have childrens in modular subpage and I suggest this change:
row 173
$parent = $this->getModularParent($cpage, $cpage); if ($parent) $extras[$parent->path()] = ['slug' => $parent->slug()];
instead of:
if ($cpage->modular()) { $this->collection->remove($cpage); $parent = $cpage->parent(); $extras[$parent->path()] = ['slug' => $parent->slug()]; }
I create this function:
protected function getModularParent($cpage, $leafPage) { $parent = null; if ($cpage->modular()) { $this->collection->remove($leafPage); $parent = $cpage->parent(); } elseif ($cpage->parent()) { $parent = $this->getModularParent($cpage->parent(), $cpage); } return $parent; }
just a todo so it's not forgotten
Whenever I make a search (doesn't matter which one), I find that in the results page ALL of the assets I load through 'shortcodes' plugin (haven't tried with assets plugin) in other pages are loaded in the head.
Example here: http://aradianoff.com/es/search/query:grav
If you look in the <head></head>
you can see scripts that shouldn't be there at all like the <style></style>
and:
<link href="http://aradianoff.com/proyectos/bergondoabierto/cuentas-bergondo/sankey.css" type="text/css" rel="stylesheet" />
<script src="http://aradianoff.com/proyectos/bergondoabierto/cuentas-bergondo/sankey.js" type="text/javascript" defer></script>
<script src="http://aradianoff.com/proyectos/bergondoabierto/cuentas-bergondo/flows.js" type="text/javascript" defer></script>
<script src="http://aradianoff.com/proyectos/bergondoabierto/cuentas-bergondo/visualization.js" type="text/javascript" defer></script>
<script src="http://aradianoff.com/proyectos/bergondoabierto/cuantos-somos/vis.standford.edu.d3.min.js" type="text/javascript" defer></script>
<script src="http://aradianoff.com/proyectos/bergondoabierto/cuantos-somos/censo_2003_2014_edad_anual.js" type="text/javascript" defer></script>
That are all of the scripts I load with 'shortcodes' in other pages. This only seems to happen in the results page of simplesearch.
Hy i have only began to work with Grav and it's verry promissing !
while i have set the blog system it auto-add simplesearch, thats a good thing but for my project i want to have that sort of form :
1 field for text input (like the plugin provide) and 2 or 3 others fields (like taxonimies) that allow a more accurate search
i have seen this plugin (https://github.com/MaZderMind/grav-plugin-urlparamfilter) but i don't know if it's possible to make all that work together if it's needed ?
Thanks in advance for all your work, and i really hope all that is possible :) !
Can I configure the plugin so the search query "foo bar" would include results that just have "foo" or just "bar"? Maybe even similar_text
above a certain percentage for misspellings? Thanks!
I just installed the SimpleSearch plugin and generally i'm happy :) but when i let the plugin search every page, and when i search for something that the default HOME page of Grav includes, then i get this result:
The titles are to close together and the note about the skeletons isn't at it should be.
Hi guys,
When adding multiple categories in the admin interface the search is not working at all. return always 0 results.
When only 1 category is used, then search is functioning as it should.
Is this an issue with simplesearch or perhaps the beta status of Grav and Admin (using both of the latest betas).
I'd like it, if there was the possibility to not just find the pages matching the keyword but also hightlight the words in the found pages. something like, that
/mygravsite/search/query:camera
shows up the search results as it is now. but clicking on a result, all found keywords will be highlighted. Eventually with paragraphs in the url like this:
/mygravsite/products/smartphone?q=camera
Would be a nice addition to the plugin.
Thanks :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.