From be0a12b5a2090c268a43a06f727bd3482e0c99c7 Mon Sep 17 00:00:00 2001 From: pixelhexe Date: Thu, 28 Nov 2024 16:57:18 +0100 Subject: [PATCH] Exclude search results 'created_by' --- administrator/language/en-GB/plg_finder_content.ini | 2 ++ plugins/finder/content/content.xml | 12 ++++++++++++ plugins/finder/content/src/Extension/Content.php | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/administrator/language/en-GB/plg_finder_content.ini b/administrator/language/en-GB/plg_finder_content.ini index 5cf0f0faa1be1..69014d3a1253c 100644 --- a/administrator/language/en-GB/plg_finder_content.ini +++ b/administrator/language/en-GB/plg_finder_content.ini @@ -16,3 +16,5 @@ PLG_FINDER_QUERY_FILTER_BRANCH_P_ARTICLE="Articles" PLG_FINDER_QUERY_FILTER_BRANCH_P_AUTHOR="Authors" PLG_FINDER_QUERY_FILTER_BRANCH_S_ARTICLE="Article" PLG_FINDER_QUERY_FILTER_BRANCH_S_AUTHOR="Author" +PLG_FINDER_CONTENT_FIELD_CREATED_BY_AUTHOR_LABEL="Include articles 'created by' (author's name)?" +PLG_FINDER_CONTENT_FIELD_CREATED_BY_AUTHOR_DESC="Switch to 'no' if you want to search only in article content ignoring the field 'created by' (author's name)." \ No newline at end of file diff --git a/plugins/finder/content/content.xml b/plugins/finder/content/content.xml index b5358e0bacc9e..ad44956f58c5d 100644 --- a/plugins/finder/content/content.xml +++ b/plugins/finder/content/content.xml @@ -45,6 +45,18 @@ + + + + diff --git a/plugins/finder/content/src/Extension/Content.php b/plugins/finder/content/src/Extension/Content.php index daa60863227c9..8ad6fe117d429 100644 --- a/plugins/finder/content/src/Extension/Content.php +++ b/plugins/finder/content/src/Extension/Content.php @@ -322,7 +322,10 @@ protected function index(Result $item) $item->addInstruction(Indexer::META_CONTEXT, 'metakey'); $item->addInstruction(Indexer::META_CONTEXT, 'metadesc'); $item->addInstruction(Indexer::META_CONTEXT, 'metaauthor'); - $item->addInstruction(Indexer::META_CONTEXT, 'author'); + // Include articles created by author + if ($this->params->get('include_created_by_author', true)) { + $item->addInstruction(Indexer::META_CONTEXT, 'author'); + } $item->addInstruction(Indexer::META_CONTEXT, 'created_by_alias'); // Translate the state. Articles should only be published if the category is published.