Added a configuration option for excluding certain pages from the results

This commit is contained in:
pontus.horn
2016-07-05 11:57:34 +02:00
parent 9a8972b599
commit 00056fde62
2 changed files with 18 additions and 1 deletions

View File

@@ -59,6 +59,14 @@ class PicoSearch extends AbstractPicoPlugin
}); });
} }
$pico = $this->getPico();
$excludes = $pico->getConfig('search_excludes');
if (!empty($excludes)) {
foreach ($excludes as $exclude_path) {
unset($pages[$exclude_path]);
}
}
if (isset($this->search_terms)) { if (isset($this->search_terms)) {
$pages = array_filter($pages, function ($page) { $pages = array_filter($pages, function ($page) {
return (stripos($page['title'], $this->search_terms) !== false) return (stripos($page['title'], $this->search_terms) !== false)

View File

@@ -58,3 +58,12 @@ template file or on a specific page.
}); });
</script> </script>
``` ```
## Configuration options
You can exclude certain pages from being included in the search results by using the configuration option `search_excludes`.
Set it to an array of pages you'd like to exclude, where each page is specified as its path relative to the content root:
```
$config['search_excludes'] = ['search', 'some/other/page'];
```