The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

Skip to content
Snippets Groups Projects
Commit 27620800 authored by Oliver Goldschmidt's avatar Oliver Goldschmidt Committed by Demian Katz
Browse files

Introduces showMore parameter

- controls how many facet values should be displayed in list
parent a190a3a0
No related merge requests found
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
*
......
......@@ -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'])?>
......
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