diff --git a/config/vufind/EDS.ini b/config/vufind/EDS.ini index 035e31bd42a52a886bdfaa3eee2d0d0b8012160e..56404656056371cb0a1839a7a03798f441db0be8 100644 --- a/config/vufind/EDS.ini +++ b/config/vufind/EDS.ini @@ -102,6 +102,12 @@ SEARCHMODE = "Search Mode" ; Facet display settings [Results_Settings] +; By default, the side facets will only show 6 facets and then the "show more" +; button. This can get configured with the showMore settings. +; You can use the * to set a new default setting. +showMore[*] = 6 +; Or you can set a facet specific value by using the facet name as index. +;showMore['SourceType'] = 10 ; Rows and columns for table used by top facets top_rows = 2 top_cols = 3 diff --git a/config/vufind/Primo.ini b/config/vufind/Primo.ini index 9a8eecb0090b9b32f0227f2d77d1ae0343d55214..1556289c996b3fb1badd2567ac602c01a3e7b359 100644 --- a/config/vufind/Primo.ini +++ b/config/vufind/Primo.ini @@ -96,6 +96,12 @@ domain = Source ; Facet display settings [Results_Settings] +; By default, the side facets will only show 6 facets and then the "show more" +; button. This can get configured with the showMore settings. +; You can use the * to set a new default setting. +showMore[*] = 6 +; Or you can set a facet specific value by using the facet name as index. +;showMore['rtype'] = 10 ; Rows and columns for table used by top facets top_rows = 2 top_cols = 3 diff --git a/config/vufind/Summon.ini b/config/vufind/Summon.ini index 43dae0de7bc96297b1d04e339f55949b68f53ffb..33bbb615788381b9f202e04ad63362a53f1cee1d 100644 --- a/config/vufind/Summon.ini +++ b/config/vufind/Summon.ini @@ -143,6 +143,12 @@ SubjectTerms = "Suggested Topics" ; Facet display settings [Results_Settings] +; By default, the side facets will only show 6 facets and then the "show more" +; button. This can get configured with the showMore settings. +; You can use the * to set a new default setting. +showMore[*] = 6 +; Or you can set a facet specific value by using the facet name as index. +;showMore['ContentType'] = 10 ; Rows and columns for table used by top facets top_rows = 2 top_cols = 3 diff --git a/config/vufind/facets.ini b/config/vufind/facets.ini index cb7db4278fa42f7183479cf3f6f3a95338d03bd7..71b19b36e207c889b7873e90518e55bdf29bd0da 100644 --- a/config/vufind/facets.ini +++ b/config/vufind/facets.ini @@ -74,6 +74,12 @@ dateRange[] = publishDate facet_limit = 30 ; Override facet_limit on a per-field basis using this array: ;facet_limit_by_field[format] = 50 +; By default, the side facets will only show 6 facets and then the "show more" +; button. This can get configured with the showMore settings. +; You can use the * to set a new default setting. +showMore[*] = 6 +; Or you can set a facet specific value by using the facet name as index. +;showMore['format'] = 10 ; Rows and columns for table used by top facets top_rows = 2 top_cols = 3 diff --git a/module/VuFind/src/VuFind/Recommend/SideFacets.php b/module/VuFind/src/VuFind/Recommend/SideFacets.php index 398b56aa3f7591fe80eec10e6bb52c5821e5878c..aa1b13611a8ed63b84f739d9de47bf192af7d22a 100644 --- a/module/VuFind/src/VuFind/Recommend/SideFacets.php +++ b/module/VuFind/src/VuFind/Recommend/SideFacets.php @@ -84,6 +84,13 @@ class SideFacets extends AbstractFacets */ protected $checkboxFacets = []; + /** + * Settings controlling how many values to display before "show more." + * + * @var array + */ + protected $showMoreSettings = []; + /** * Collapsed facet setting * @@ -181,6 +188,12 @@ class SideFacets extends AbstractFacets $this->checkboxFacets = array_flip($this->checkboxFacets); } + // Show more settings: + if (isset($config->Results_Settings->showMore)) { + $this->showMoreSettings + = $config->Results_Settings->showMore->toArray(); + } + // Collapsed facets: if (isset($config->Results_Settings->collapsedFacets)) { $this->collapsedFacets = $config->Results_Settings->collapsedFacets; @@ -333,6 +346,27 @@ class SideFacets extends AbstractFacets return array_map('trim', explode(',', $this->collapsedFacets)); } + /** + * Return the list of facets configured to be collapsed + * + * @param string $facetName Name of the facet to get + * + * @return int + */ + public function getShowMoreSetting($facetName = '*') + { + // Look for either facet-specific configuration or else a configured + // default. If neither is found, initialize return value to 0. + if (isset($this->showMoreSettings[$facetName])) { + $val = intval($this->showMoreSettings[$facetName]); + } elseif (isset($this->showMoreSettings['*'])) { + $val = intval($this->showMoreSettings['*']); + } + + // Validate the return value, defaulting to 6 if missing/invalid + return (isset($val) && $val > 0) ? $val : 6; + } + /** * Get the list of filters to display * diff --git a/themes/bootstrap3/templates/Recommend/SideFacets.phtml b/themes/bootstrap3/templates/Recommend/SideFacets.phtml index 1a7e851655b0b38eb80be738fe13d9837c3b282d..562632c0e88542ac25b085ccecd1036e168d49af 100644 --- a/themes/bootstrap3/templates/Recommend/SideFacets.phtml +++ b/themes/bootstrap3/templates/Recommend/SideFacets.phtml @@ -56,6 +56,7 @@ <? if (!empty($sideFacetSet) && $results->getResultTotal() > 0): ?> <? foreach ($sideFacetSet as $title => $cluster): ?> <? $allowExclude = $this->recommend->excludeAllowed($title); ?> + <? $facets_before_more = $this->recommend->getShowMoreSetting($title); ?> <div class="list-group facet" id="side-panel-<?=$this->escapeHtmlAttr($title) ?>"> <div class="list-group-item title<? if(in_array($title, $collapsedFacets)): ?> collapsed<? endif ?>" data-toggle="collapse" href="#side-collapse-<?=$this->escapeHtmlAttr($title) ?>" > <?=$this->transEsc($cluster['label'])?> @@ -160,11 +161,11 @@ JS; } ?> <? $moreClass = 'narrowGroupHidden-'.$this->escapeHtmlAttr($title).' hidden'; ?> - <? if ($i == 6): ?> + <? if ($i == $facets_before_more): ?> <a id="more-narrowGroupHidden-<?=$this->escapeHtmlAttr($title)?>" class="list-group-item narrow-toggle" href="javascript:moreFacets('narrowGroupHidden-<?=$title ?>')"><?=$this->transEsc('more')?> ...</a> <? endif; ?> <? if ($thisFacet['isApplied']): ?> - <a class="list-group-item active<? if ($i>5): ?><?=$moreClass ?><?endif ?><? if ($thisFacet['operator'] == 'OR'): ?> facetOR applied<? endif ?>" href="<?=$this->currentPath().$results->getUrlQuery()->removeFacet($title, $thisFacet['value'], true, $thisFacet['operator']) ?>"> + <a class="list-group-item active<? if ($i >= $facets_before_more): ?><?=$moreClass ?><?endif ?><? if ($thisFacet['operator'] == 'OR'): ?> facetOR applied<? endif ?>" href="<?=$this->currentPath().$results->getUrlQuery()->removeFacet($title, $thisFacet['value'], true, $thisFacet['operator']) ?>"> <? if ($thisFacet['operator'] == 'OR'): ?> <i class="fa fa-check-square-o"></i> <? else: ?> @@ -175,9 +176,9 @@ JS; <? else: ?> <? $addURL = $this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'], $thisFacet['operator']); ?> <? if ($allowExclude): ?> - <div class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i>5): ?> <?=$moreClass ?><?endif ?>"> + <div class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i >= $facets_before_more): ?> <?=$moreClass ?><?endif ?>"> <? else: ?> - <a href="<?=$addURL ?>" class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i>5): ?> <?=$moreClass ?><?endif ?>"> + <a href="<?=$addURL ?>" class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i >= $facets_before_more): ?> <?=$moreClass ?><?endif ?>"> <? endif; ?> <span class="badge"> <?=$this->localizedNumber($thisFacet['count'])?>