[Koha-patches] [PATCH] bug4891 - sort facets in search sidebar (OPAC and staff client)
Robin Sheat
robin at catalyst.net.nz
Fri Dec 17 00:16:17 CET 2010
---
catalogue/search.pl | 6 ++++++
opac/opac-search.pl | 7 +++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/catalogue/search.pl b/catalogue/search.pl
index ac2209a..8cb737d 100755
--- a/catalogue/search.pl
+++ b/catalogue/search.pl
@@ -499,6 +499,12 @@ if (C4::Context->preference('NoZebra')) {
($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
};
}
+# This sorts the facets into alphabetical order
+if ($facets) {
+ foreach my $f (@$facets) {
+ $f->{facets} = [ sort { uc($a->{facet_title_value}) cmp uc($b->{facet_title_value}) } @{ $f->{facets} } ];
+ }
+}
if ($@ || $error) {
$template->param(query_error => $error.$@);
output_html_with_http_headers $cgi, $cookie, $template->output;
diff --git a/opac/opac-search.pl b/opac/opac-search.pl
index 88f3a2f..45cb766 100755
--- a/opac/opac-search.pl
+++ b/opac/opac-search.pl
@@ -422,6 +422,13 @@ elsif (C4::Context->preference('NoZebra')) {
($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
};
}
+# This sorts the facets into alphabetical order
+if ($facets) {
+ foreach my $f (@$facets) {
+ $f->{facets} = [ sort { uc($a->{facet_title_value}) cmp uc($b->{facet_title_value}) } @{ $f->{facets} } ];
+ }
+}
+
# use Data::Dumper; print STDERR "-" x 25, "\n", Dumper($results_hashref);
if ($@ || $error) {
$template->param(query_error => $error.$@);
--
1.7.1
More information about the Koha-patches
mailing list