From 9f672651f433c6be8e6909defcd001705b0827cd Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Fri, 15 Dec 2023 09:43:22 -0500 Subject: [PATCH] Make default sort configurable for new items. --- config/vufind/searches.ini | 2 ++ .../VuFind/src/VuFind/Controller/Plugin/NewItems.php | 10 ++++++++++ .../VuFind/src/VuFind/Controller/SearchController.php | 1 + themes/bootstrap3/templates/search/newitem.phtml | 3 +++ 4 files changed, 16 insertions(+) diff --git a/config/vufind/searches.ini b/config/vufind/searches.ini index a86e0e18875..0fa54d01400 100644 --- a/config/vufind/searches.ini +++ b/config/vufind/searches.ini @@ -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 diff --git a/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php b/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php index 770ea14b185..cf23cb54217 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php @@ -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 * diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index 6a1d8ce7549..6a28bb096b6 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -237,6 +237,7 @@ public function newitemAction() return $this->createViewModel( [ + 'defaultSort' => $this->newItems()->getDefaultSort(), 'fundList' => $this->newItems()->getFundList(), 'ranges' => $this->newItems()->getRanges(), ] diff --git a/themes/bootstrap3/templates/search/newitem.phtml b/themes/bootstrap3/templates/search/newitem.phtml index 4a3954c10d1..07644d414cd 100644 --- a/themes/bootstrap3/templates/search/newitem.phtml +++ b/themes/bootstrap3/templates/search/newitem.phtml @@ -13,6 +13,9 @@ render('Helpers/ils-offline.phtml', ['offlineModeMsg' => 'ils_offline_holdings_message'])?>
+ defaultSort)): ?> + +