diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index 2a1a2c9848e..af48dbffca3 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -297,6 +297,10 @@ public function newitemresultsAction() $this->getRequest()->getQuery()->set('hiddenFilters', $hiddenFilters); } + // Flag this as a specialized search to avoid bleeding defaults into the + // standard search box: + $this->getRequest()->getQuery()->set('specializedSearch', true); + // Don't save to history or memory -- history page doesn't handle correctly // and we don't want hidden filters bleeding to weird places: $this->saveToHistory = false; diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php index a8c35427d4e..c8f58601ce4 100644 --- a/module/VuFind/src/VuFind/Search/Base/Params.php +++ b/module/VuFind/src/VuFind/Search/Base/Params.php @@ -241,6 +241,14 @@ class Params */ protected $queryAdapterClass = QueryAdapter::class; + /** + * Is this a specialized search (i.e. a customized scenario like new items, + * rather than a "normal" backend search)? + * + * @var bool + */ + protected $isSpecializedSearch = false; + /** * Constructor * @@ -369,6 +377,7 @@ public function initFromRequest($request) $this->initSort($request); $this->initFilters($request); $this->initHiddenFilters($request); + $this->isSpecializedSearch = $request->get('specializedSearch', false); } /** @@ -2102,4 +2111,15 @@ public function supportsFacetFiltering($facet) $translatedFacets = $this->getOptions()->getTranslatedFacets(); return method_exists($this, 'setFacetContains') && !in_array($facet, $translatedFacets); } + + /** + * Is this a specialized search (i.e. a customized scenario like new items, + * rather than a "normal" backend search)? + * + * @var bool + */ + public function isSpecializedSearch(): bool + { + return $this->isSpecializedSearch; + } } diff --git a/themes/bootstrap3/templates/search/searchbox.phtml b/themes/bootstrap3/templates/search/searchbox.phtml index 9e87599df7e..ae7c9763217 100644 --- a/themes/bootstrap3/templates/search/searchbox.phtml +++ b/themes/bootstrap3/templates/search/searchbox.phtml @@ -9,7 +9,7 @@ ?? 'Solr'; } // Initialize from current search if eligible, defaults otherwise: - if (isset($params) && $this->searchClassId === $params->getSearchClassId()) { + if (isset($params) && $this->searchClassId === $params->getSearchClassId() && !$params->isSpecializedSearch()) { $hiddenFilters = $params->getHiddenFilters(); $lastSort = $params->getSort(); $lastLimit = $params->getLimit(); diff --git a/themes/bootstrap5/templates/search/searchbox.phtml b/themes/bootstrap5/templates/search/searchbox.phtml index 5ee2ac26067..4f2278a2aba 100644 --- a/themes/bootstrap5/templates/search/searchbox.phtml +++ b/themes/bootstrap5/templates/search/searchbox.phtml @@ -9,7 +9,7 @@ ?? 'Solr'; } // Initialize from current search if eligible, defaults otherwise: - if (isset($params) && $this->searchClassId === $params->getSearchClassId()) { + if (isset($params) && $this->searchClassId === $params->getSearchClassId() && !$params->isSpecializedSearch()) { $hiddenFilters = $params->getHiddenFilters(); $lastSort = $params->getSort(); $lastLimit = $params->getLimit();