From 13bc505c5ffdd22533b49ddc4d1e79ecce49ed4d Mon Sep 17 00:00:00 2001 From: Robin Sheat Date: Thu, 16 Dec 2010 02:50:08 -0500 Subject: [PATCH] bug4891 - sort facets in search sidebar (OPAC and staff client) Signed-off-by: Nicole Engard Signed-off-by: Chris Cormack --- catalogue/search.pl | 6 ++++++ opac/opac-search.pl | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/catalogue/search.pl b/catalogue/search.pl index ac2209af34..8cb737d323 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 88f3a2fa95..45cb7664a6 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.$@); -- 2.39.5