From cb01d9aa67a64d3a22d48a0bccf99431725b218b Mon Sep 17 00:00:00 2001 From: Robin Sheat Date: Fri, 17 Dec 2010 12:13:54 +1300 Subject: [PATCH] bug4891 - sort facets in search sidebar (OPAC and staff client) --- 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