How can I configure simplesearch plugin to search only visibile or routable pages?
Doesn’t it already do that by default? If a page is not set as “published,” then it should not appear.
My question is how to get only visible (page.header.visible == true) and/or routable (page.header.routable == true) pages in search result.
After a quick look through the source code, I see no way to do that using this plugin. It is “simple” search, after all I still don’t quite understand what you’re trying to accomplish. visible
makes the page visible in navigation. And unless explicitly set, all published
pages are routable. I’m not sure what exact subset of pages you’re trying to reach.
In any case, the simplesearch plugin works based on taxonomy. That’s it. You’d need to write another plugin or submit a pull request to accomplish what it sounds like you’re trying to do.
It seems to me that page appears even when published = false
. I think that page collection have to be filtered by Collection::published()
and Collection::routable()
. The second one because I think It does not make sense to make page appear when is not routable. It’s right?
I agree with the OP as I ran into this same behaviour in a project this week.
The plugin currently shows results (links to pages) that are explicitly marked “published: false”. In my opinion, this is not the intuitive, expected behaviour. It would be better to have unpublished pages filtered out by default and have a configurable setting to override that.
Also, “routable: false” pages should be left out of the results by default. The search result is basically a link and, if the page isn’t routable, that link won’t work.
I have created a pull request in repository.