Skip to content

Commit

Permalink
Disable hidden filters completely for New Items.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Jan 17, 2025
1 parent 5e148ae commit 7d67a7d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions module/VuFind/src/VuFind/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ public function newitemresultsAction()
}

// We don't want new items hidden filters to propagate to other searches:
$this->serviceLocator->get('ViewHelperManager')->get('searchTabs')->disableHiddenFilterParams();
$view->ignoreHiddenFiltersInRequest = true;

return $view;
Expand Down
21 changes: 21 additions & 0 deletions module/VuFind/src/VuFind/View/Helper/Root/SearchTabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ class SearchTabs extends \Laminas\View\Helper\AbstractHelper
*/
protected $cachedHiddenFilterParams = [];

/**
* Are hidden filter params disabled?
*
* @var bool
*/
protected $hiddenFilterParamsDisabled = false;

/**
* Constructor
*
Expand Down Expand Up @@ -229,6 +236,9 @@ public function getCurrentHiddenFilterParams(
$ignoreHiddenFilterMemory = false,
$prepend = '&'
) {
if ($this->hiddenFilterParamsDisabled) {
return '';
}
if (!isset($this->cachedHiddenFilterParams[$searchClassId])) {
$view = $this->getView();
$hiddenFilters = $this->getHiddenFilters(
Expand Down Expand Up @@ -371,4 +381,15 @@ protected function buildUrlHiddenFilters(
}
return '';
}

/**
* Disable hidden filter params (used in contexts like New Items where we don't
* want to persist hidden filters through links).
*
* @return void
*/
public function disableHiddenFilterParams(): void
{
$this->hiddenFilterParamsDisabled = true;
}
}

0 comments on commit 7d67a7d

Please sign in to comment.