Skip to content

Commit

Permalink
Make default sort configurable for new items.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Dec 15, 2023
1 parent 4272a6a commit 9f67265
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/vufind/searches.ini
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ ranges = 1,5,30
; set the value too low, you may get the same results no matter which range setting
; is selected!
result_pages = 10
; The default sort to use (if different from the normally configured default).
;default_sort = year
; This setting can be used to automatically apply filter queries to the New Item
; results. For example, you might want to filter out certain content types. You
; can add multiple filters by repeating the "filter[] =" line, or you can skip
Expand Down
10 changes: 10 additions & 0 deletions module/VuFind/src/VuFind/Controller/Plugin/NewItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ public function getBibIDsFromCatalog($catalog, $params, $range, $dept, $flash)
return $bibIDs;
}

/**
* Get default setting (null to use regular default).
*
* @return ?string
*/
public function getDefaultSort(): ?string
{
return $this->config->default_sort ?? null;
}

/**
* Get fund list
*
Expand Down
1 change: 1 addition & 0 deletions module/VuFind/src/VuFind/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public function newitemAction()

return $this->createViewModel(
[
'defaultSort' => $this->newItems()->getDefaultSort(),
'fundList' => $this->newItems()->getFundList(),
'ranges' => $this->newItems()->getRanges(),
]
Expand Down
3 changes: 3 additions & 0 deletions themes/bootstrap3/templates/search/newitem.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<?=$this->render('Helpers/ils-offline.phtml', ['offlineModeMsg' => 'ils_offline_holdings_message'])?>
<?php endif; ?>
<form method="get" class="form-search-newitem">
<?php if (!empty($this->defaultSort)): ?>
<input type="hidden" name="sort" value="<?=$this->escapeHtmlAttr($this->defaultSort)?>">
<?php endif; ?>
<div class="form-group">
<label class="control-label"><?=$this->transEsc('Range')?>:</label>
<div class="btn-group" data-toggle="buttons">
Expand Down

0 comments on commit 9f67265

Please sign in to comment.