Added a configuration option for excluding certain pages from the results
This commit is contained in:
@@ -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)) {
|
||||
$pages = array_filter($pages, function ($page) {
|
||||
return (stripos($page['title'], $this->search_terms) !== false)
|
||||
|
||||
11
README.md
11
README.md
@@ -57,4 +57,13 @@ template file or on a specific page.
|
||||
e.preventDefault();
|
||||
});
|
||||
</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'];
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user