Skip to content
Snippets Groups Projects
Commit 21c9121c authored by Demian Katz's avatar Demian Katz
Browse files

Resolved VUFIND-603 (added optional alphabetical sorting of browse lists).

parent 24d6cf85
No related merge requests found
...@@ -642,6 +642,10 @@ region = true ; allow browsing of region subdivisions ...@@ -642,6 +642,10 @@ region = true ; allow browsing of region subdivisions
era = true ; allow browsing of era subdivisions era = true ; allow browsing of era subdivisions
; You can use this setting to change the default alphabet provided for browsing: ; You can use this setting to change the default alphabet provided for browsing:
;alphabet_letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;alphabet_letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
; Uncomment to sort lists alphabetically (instead of by popularity); note that
; this will not changed the values returned -- you will still get only the
; <result_limit> most popular entries -- it only affects display order.
;alphabetical_order = true
; This section controls which record export methods are displayed on the Record ; This section controls which record export methods are displayed on the Record
; view screen. Note that some options may be disabled for records that do not ; view screen. Note that some options may be disabled for records that do not
......
...@@ -581,6 +581,17 @@ class BrowseController extends AbstractBase ...@@ -581,6 +581,17 @@ class BrowseController extends AbstractBase
$params->setFacetSort($sort); $params->setFacetSort($sort);
$result = $searchObject->getFacetList(); $result = $searchObject->getFacetList();
if (isset($result[$facet])) { if (isset($result[$facet])) {
// Sort facets alphabetically if configured to do so:
if (isset($this->config->Browse->alphabetical_order)
&& $this->config->Browse->alphabetical_order) {
if (isset($this->config->Site->locale)) {
setlocale(LC_ALL, $this->config->Site->locale . ".utf8");
$callback = function ($a, $b) {
return strcoll($a['displayText'], $b['displayText']);
};
usort($result[$facet]['list'], $callback);
}
}
return $result[$facet]['list']; return $result[$facet]['list'];
} else { } else {
return array(); return array();
......
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