Skip to content
Snippets Groups Projects
Commit 2e5d6ce7 authored by Robert Lange's avatar Robert Lange Committed by Sebastian Kehr
Browse files

refs #15579 [master-v5]

* add finc facetList for content blocks
* remove ils offline message from finc facetlist
* should be implemented by parent theme(s), for instance home.phtml
parent 48a618d7
Branches
Tags instance/finc/staging/20210930_111555
No related merge requests found
<!-- finc: ContentBlock -- FacetList -->
<?php
// Load search actions and settings (if any):
$options = $this->searchOptions($searchClassId);
$basicSearch = $options->getSearchAction();
$advSearch = $options->getAdvancedSearchAction();
$noJsSupport = $this->config()->nonJavascriptSupportEnabled();
?>
<?php if (!empty($facetList)): ?>
<div class="search-home-facets">
<?php
$itemSum = $fieldSum = 0;
$maxColumns = 4;
foreach ($facetList as $field => $details) {
$itemSum += count($details['list']);
$fieldSum += 1;
}
?>
<?php foreach ($facetList as $field => $details): ?>
<?php if ($isHierarchy = in_array($field, $hierarchicalFacets ?? [])):
$this->headScript()->appendFile('vendor/jsTree/jstree.min.js');
$this->headScript()->appendFile('facets.js');
$sort = $hierarchicalFacetSortOptions[$field] ?? '';
$script = <<<JS
$(document).ready(function() {
$('#facet_{$this->escapeHtml($field)}_container').removeClass('hide');
initFacetTree($('#facet_{$this->escapeHtml($field)}'), false);
});
JS;
echo $this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET');
?>
<div id="facet_<?=$this->escapeHtml($field)?>_container" class="home-facet <?=$this->escapeHtmlAttr($field)?> hide">
<h2><?=$this->transEsc('home_browse') . ' ' . $this->transEsc($details['label'])?></h2>
<div id="facet_<?=$this->escapeHtml($field)?>" class="jstree-facet"
data-source="<?=$this->escapeHtml($this->searchClassId)?>"
data-facet="<?=$this->escapeHtml($field)?>"
data-path="<?=$this->url($basicSearch)?>"
data-exclude="0"
data-operator="AND"
data-exclude-title="<?=$this->transEsc('exclude_facet')?>"
data-sort="all">
</div>
</div>
<noscript>
<?php if (!$noJsSupport): ?>
<h2><?=$this->transEsc('home_browse') . ' ' . $this->transEsc($details['label'])?></h2>
<?=$this->transEsc('Please enable JavaScript.')?>
<?php endif; ?>
<?php endif; ?>
<?php if (!$isHierarchy || $noJsSupport): // do we need regular display? ?>
<?php $sortedList = $this->sortFacetList($results, $field, $details['list'], $basicSearch); ?>
<div class="home-facet <?=$this->escapeHtmlAttr($field) ?>">
<h2><?=$this->transEsc('home_browse') . ' ' . $this->transEsc($details['label'])?></h2>
<div class="home-facet-container">
<ul class="home-facet-list">
<?php
// Convenience variable:
$currentListLength = count($sortedList);
// Special case: two columns for LC call numbers...
$maxListLength = $field == 'callnumber-first'
|| ($currentListLength * 2 >= $itemSum && $fieldSum < $maxColumns) // #15579 ... or outnumbered facets
? $columnSize * 2 : $columnSize;
// Special case: custom URLs for collections...
$moreUrl = $field == 'hierarchy_top_title'
? $this->url('collections-home') : $this->url($advSearch);
?>
<?php $i = 0; foreach ($sortedList as $url => $value):
// Special case: custom URLs for collections...
if ($field == 'hierarchy_top_title') {
$url = $this->url('collections-bytitle') . '?title=' . urlencode($value);
}
?>
<li><a href="<?=$url?>"><?=$this->escapeHtml(empty($value) ? '-' : $value)?></a></li>
<?php if (++$i >= $currentListLength) break; // end of list? bail out! ?>
<?php if ($i >= $maxListLength): // list too long? show more link! ?>
<li><a href="<?=$moreUrl?>"><strong><?=$this->transEsc("More options")?>...</strong></a></li>
<?php break; ?>
<?php elseif ($i % $columnSize === 0): // end of column? insert break! ?>
</ul><ul class="home-facet-list">
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php endif; ?>
<?php if ($isHierarchy): // close tag opened in matching if above ?>
</noscript>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<!-- finc: ContentBlock -- FacetList - END -->
\ No newline at end of file
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