Skip to content
Snippets Groups Projects
Commit 8f2e73de authored by Ere Maijala's avatar Ere Maijala Committed by Robert Lange
Browse files

Fix filters displaying on home or record page when retain_filters_by_default = false. (#1482)

parent 4ad91e1e
No related merge requests found
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
$results = $this->tab->getResults(); $results = $this->tab->getResults();
$params = $this->tab->getParams(); $params = $this->tab->getParams();
$searchDetails = ['results' => $results, 'params' => $params, 'indexStart' => 1]; $searchDetails = ['results' => $results, 'params' => $params, 'indexStart' => 1];
$filterList = $params->getFilterList(false);
$checkboxFilters = $params->getCheckboxFacets();
?> ?>
<div class="<?=$this->layoutClass('mainbody')?>"> <div class="<?=$this->layoutClass('mainbody')?>">
<?php if (($recordTotal = $results->getResultTotal()) > 0): // only display these at very top if we have results ?> <?php if (($recordTotal = $results->getResultTotal()) > 0): // only display these at very top if we have results ?>
...@@ -42,11 +45,15 @@ ...@@ -42,11 +45,15 @@
</div> </div>
</div> </div>
<?php if (!empty($params->getFilterList(false))): ?>
<?php if ($filterList || $checkboxFilters): ?>
<?=$this->render('search/filters.phtml', <?=$this->render('search/filters.phtml',
[ [
'params' => $params,
'urlQuery' => $results->getUrlQuery(), 'urlQuery' => $results->getUrlQuery(),
'filterList' => $filterList,
'checkboxFilters' => $checkboxFilters,
'searchClassId' => $this->searchClassId,
'searchType' => 'basic',
] ]
); ?> ); ?>
<?php endif; ?> <?php endif; ?>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
'searchId' => $this->results->getSearchId(), 'searchId' => $this->results->getSearchId(),
'searchClassId' => $this->params->getSearchClassId(), 'searchClassId' => $this->params->getSearchClassId(),
'checkboxFilters' => $this->params->getCheckboxFacets(), 'checkboxFilters' => $this->params->getCheckboxFacets(),
'filterList' => $this->params->getFilters(), 'filterList' => $this->params->getFilterList(),
'hasDefaultsApplied' => $this->params->hasDefaultsApplied(), 'hasDefaultsApplied' => $this->params->hasDefaultsApplied(),
'selectedShards' => $this->params->getSelectedShards() 'selectedShards' => $this->params->getSelectedShards()
] ]
......
...@@ -7,10 +7,8 @@ ...@@ -7,10 +7,8 @@
$params = clone $this->params; $params = clone $this->params;
} }
$filterList = $params->getFilterList(true); $lastSort = $this->searchMemory()->getLastSort($this->searchClassId);
$checkboxFilters = $params->getCheckboxFacets(); $options = $this->searchOptions($this->searchClassId);
$lastSort = $this->searchMemory()->getLastSort($params->getSearchClassId());
$options = $this->searchOptions($params->getSearchClassId());
$hasDefaultsApplied = $params->hasDefaultsApplied(); $hasDefaultsApplied = $params->hasDefaultsApplied();
$filterCount = $this->searchbox()->getFilterCount($checkboxFilters, $filterList); $filterCount = $this->searchbox()->getFilterCount($checkboxFilters, $filterList);
...@@ -25,7 +23,7 @@ ...@@ -25,7 +23,7 @@
} }
} }
$advancedSearch = $params->getSearchType() === 'advanced'; $advancedSearch = $this->searchType === 'advanced';
?> ?>
<?php ob_start(); ?> <?php ob_start(); ?>
<?php foreach ($checkboxFilters as $filter): ?> <?php foreach ($checkboxFilters as $filter): ?>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
'searchId' => $this->results->getSearchId(), 'searchId' => $this->results->getSearchId(),
'searchClassId' => $this->params->getSearchClassId(), 'searchClassId' => $this->params->getSearchClassId(),
'checkboxFilters' => $this->params->getCheckboxFacets(), 'checkboxFilters' => $this->params->getCheckboxFacets(),
'filterList' => $this->params->getFilters(), 'filterList' => $this->params->getFilterList(),
'hasDefaultsApplied' => $this->params->hasDefaultsApplied(), 'hasDefaultsApplied' => $this->params->hasDefaultsApplied(),
'selectedShards' => $this->params->getSelectedShards(), 'selectedShards' => $this->params->getSelectedShards(),
'ignoreHiddenFiltersInRequest' => isset($this->ignoreHiddenFiltersInRequest) ? $this->ignoreHiddenFiltersInRequest : false, 'ignoreHiddenFiltersInRequest' => isset($this->ignoreHiddenFiltersInRequest) ? $this->ignoreHiddenFiltersInRequest : false,
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
$checkboxFilters = is_array($this->checkboxFilters) ? $this->checkboxFilters : []; $checkboxFilters = is_array($this->checkboxFilters) ? $this->checkboxFilters : [];
} }
$filterDetails = $this->searchbox()->getFilterDetails($filterList, $checkboxFilters); $filterDetails = $this->searchbox()->getFilterDetails($filterList, $checkboxFilters);
$showFilters = $filterDetails && (isset($results) || $options->getRetainFilterSetting());
?> ?>
<?php $tabConfig = $this->searchTabs()->getTabConfig($this->searchClassId, $this->lookfor, $this->searchIndex, $this->searchType, $hiddenFilters); ?> <?php $tabConfig = $this->searchTabs()->getTabConfig($this->searchClassId, $this->lookfor, $this->searchIndex, $this->searchType, $hiddenFilters); ?>
<?php if ($this->searchType == 'advanced'): ?> <?php if ($this->searchType == 'advanced'): ?>
...@@ -52,7 +53,11 @@ ...@@ -52,7 +53,11 @@
'search/filters.phtml', 'search/filters.phtml',
[ [
'params' => $params ?? null, 'params' => $params ?? null,
'urlQuery' => isset($results) ? $results->getUrlQuery() : null 'urlQuery' => isset($results) ? $results->getUrlQuery() : null,
'filterList' => $showFilters ? $filterList : [],
'checkboxFilters' => $showFilters ? $checkboxFilters : [],
'searchClassId' => $this->searchClassId,
'searchType' => $this->searchType,
] ]
);?> );?>
<?php if (!empty($tabs)): ?></div><?php endif; ?> <?php if (!empty($tabs)): ?></div><?php endif; ?>
...@@ -140,7 +145,11 @@ ...@@ -140,7 +145,11 @@
'search/filters.phtml', 'search/filters.phtml',
[ [
'params' => $params ?? null, 'params' => $params ?? null,
'urlQuery' => isset($results) ? $results->getUrlQuery() : null 'urlQuery' => isset($results) ? $results->getUrlQuery() : null,
'filterList' => $showFilters ? $filterList : [],
'checkboxFilters' => $showFilters ? $checkboxFilters : [],
'searchClassId' => $this->searchClassId,
'searchType' => $this->searchType,
] ]
);?> );?>
</form> </form>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment