From 00056fde627b8952f741cc230a0edc86cecde48f Mon Sep 17 00:00:00 2001 From: "pontus.horn" Date: Tue, 5 Jul 2016 11:57:34 +0200 Subject: [PATCH] Added a configuration option for excluding certain pages from the results --- 40-PicoSearch.php | 8 ++++++++ README.md | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/40-PicoSearch.php b/40-PicoSearch.php index 9ba752a..7360ca3 100644 --- a/40-PicoSearch.php +++ b/40-PicoSearch.php @@ -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) diff --git a/README.md b/README.md index 426f1a7..f7f2e79 100644 --- a/README.md +++ b/README.md @@ -57,4 +57,13 @@ template file or on a specific page. e.preventDefault(); }); -``` \ No newline at end of file +``` + +## 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']; +```