Skip to content

Commit

Permalink
Added own templates for RecordTab controls
Browse files Browse the repository at this point in the history
  • Loading branch information
LuomaJuha committed Sep 17, 2024
1 parent 6f92323 commit d3cb5dc
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 3 deletions.
4 changes: 2 additions & 2 deletions themes/finna2/templates/RecordTab/collectionlist.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
</div>
</form>
</div>
<?=$this->render('search/controls/view.phtml', $searchDetails)?>
<?=$this->render('search/controls/sort.phtml', $searchDetails)?>
<?=$this->render('RecordTab/controls/view.phtml', $searchDetails)?>
<?=$this->render('RecordTab/controls/sort.phtml', $searchDetails)?>
</div>

<div class="mainbody left">
Expand Down
47 changes: 47 additions & 0 deletions themes/finna2/templates/RecordTab/controls/sort.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!-- START of: finna - RecordTab/controls/sort.phtml -->
<?php $list = $this->sortList ? $this->sortList : $this->params->getSortList();
if (empty($list)) {
return;
}?>
<div class="sort-option-container">
<span class="hidden-sm hidden-xs hidden-md button-label" id="sort-label"><?=$this->transEsc('Sort')?></span>
<span class="sr-only hidden-lg hidden-md"><?=$this->transEsc('Sort')?></span>
<div class="sort-button">
<div class="dropdown">
<?php $selectedFound = false; ?>
<?php foreach ($list as $sortType => $sortData): ?>
<?php if ($sortData['selected']): ?>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-label="<?= $this->transEsc('Sort') . ': ' . $this->transEsc($sortData['desc'])?>">
<span><?=$this->transEsc($sortData['desc'])?></span> <?=$this->icon('dropdown-open') ?>
</a>
<?php $selectedFound = true; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php if (!$selectedFound): ?>
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span><?=$this->transEsc('choose_from_list')?></span> <?=$this->icon('dropdown-open') ?>
</a>
<?php endif; ?>
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="sort-label">
<?php foreach ($list as $sortType => $sortData): ?>
<li>
<a href="Results<?=isset($sortData['url']) ? $this->escapeHtmlAttr($sortData['url']) : $this->results->getUrlQuery()->setSort($sortType)?>" role="menuitem" aria-label="<?= $this->transEsc('Sort') . ': ' . $this->transEsc($sortData['desc'])?>"><?=$this->transEsc($sortData['desc'])?></a>
<?php endforeach; ?>
</li>
</ul>
<noscript><input type="submit" class="btn btn-default" value="<?=$this->transEscAttr('Set')?>"></noscript>
</div>
</div>
</div>
<?php // Use a hidden form for upstream JS results compatibility: ?>
<form class="search-sort hidden" action="<?=$this->currentPath()?>" method="get" name="sort">
<?=$this->results->getUrlQuery()->asHiddenFields(['sort' => '/.*/', 'page' => '/.*/']);?>
<label for="sort_options_1"><?=$this->transEsc('Sort')?></label>
<select id="sort_options_1" name="sort" class="jumpMenu form-control">
<?php foreach ($list as $sortType => $sortData): ?>
<option value="<?=$this->escapeHtmlAttr($sortType)?>"<?=$sortData['selected'] ? ' selected="selected"' : ''?><?=$sortData['default'] ? ' data-default' : ''?>><?=$this->transEsc($sortData['desc'])?></option>
<?php endforeach; ?>
</select>
<noscript><input type="submit" class="btn btn-default" value="<?=$this->transEscAttr('Set')?>"></noscript>
</form>
<!-- END of: finna - RecordTab/controls/sort.phtml -->
41 changes: 41 additions & 0 deletions themes/finna2/templates/RecordTab/controls/view.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!-- START of: finna - RecordTab/controls/view.phtml -->
<?php
$viewList = $this->params->getViewList();
if (count($viewList) <= 1) {
return;
}
?>
<div class="view-option-container text-right">
<span class="hidden-sm hidden-xs hidden-md button-label" id="show-as-label"><?=$this->transEsc('show_as')?></span>
<span class="sr-only hidden-lg hidden-md"><?=$this->transEsc('show_as')?></span>
<div class="view-dropdown">
<div class="dropdown">
<?php foreach ($viewList as $viewType => $viewData): ?>
<?php if ($viewData['selected']): ?>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-label="<?=$this->transEsc('show_as') . ': ' . $this->transEsc('Show As ' . $viewData['desc'])?>"><?=$this->icon('view-' . $viewType, 'icon-' . $viewType) ?> <span class="hidden-xs hidden-sm"><?=$this->transEsc('Show As ' . $viewData['desc'])?></span> <?=$this->icon('dropdown-open') ?></a>
<?php endif; ?>
<?php endforeach; ?>

<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="show-as-label">
<?php foreach ($viewList as $viewType => $viewData): ?>
<?php
if ($viewData['selected']) {
$viewUrl = '#';
} else {
$viewUrl = $this->results->getUrlQuery()->setViewParam($viewType);
if ('visual' === $viewType) {
$viewUrl = $viewUrl->setPage(1);
}
}
?>
<li>
<a href="<?=$viewUrl?>" title="<?=$this->transEsc($viewData['desc'])?>" role="menuitem" aria-label="<?=$this->transEsc('show_as') . ': ' . $this->transEsc('Show As ' . $viewData['desc'])?>" >
<?=$this->icon('view-' . $viewType, 'icon-' . $viewType) ?> <?=$this->transEsc('Show As ' . $viewData['desc'])?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<!-- END of: finna - RecordTab/controls/view.phtml -->
4 changes: 3 additions & 1 deletion themes/finna2/templates/search/controls/view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
if (count($viewList) <= 1) {
return;
}
$viewOptionsIcons = (!($isCollection ?? false)) && is_callable([$this->params, 'getViewOptionListType']) ? $this->params->getViewOptionListType() : null;
$viewOptionsIcons = !($this->params instanceof \VuFind\Search\SolrCollection\Params) && is_callable([$this->params, 'getViewOptionListType'])
? $this->params->getViewOptionListType()
: null;
?>
<div class="view-option-container text-right">
<span class="hidden-sm hidden-xs hidden-md button-label"<?php if (!$viewOptionsIcons): ?> id="show-as-label"<?php endif;?>><?=$this->transEsc('show_as')?></span>
Expand Down

0 comments on commit d3cb5dc

Please sign in to comment.