[Koha-patches] [PATCH] Bug 6154: Default sorting by title doesn't work

Ian Walls ian.walls at bywatersolutions.com
Sun Apr 10 23:28:05 CEST 2011


From: Jared Camins-Esakov <jcamins at bywatersolutions.com>

If you have the default sorting set to title ascending or title descending,
your search results will not automatically be sorted because the syspref uses
title_asc and title_dsc, whereas Search.pm wants title_az and title_za. The same
issue is present when the default sort is on author.

Signed-off-by: Ian Walls <ian.walls at bywatersolutions.com>
---
 C4/Search.pm |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/C4/Search.pm b/C4/Search.pm
index a8d6625..ab7cb59 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -359,10 +359,10 @@ sub getRecords {
         # Note: sort will override rank
         my $sort_by;
         foreach my $sort (@sort_by) {
-            if ( $sort eq "author_az" ) {
+            if ( $sort eq "author_az" || $sort eq "author_asc" ) {
                 $sort_by .= "1=1003 <i ";
             }
-            elsif ( $sort eq "author_za" ) {
+            elsif ( $sort eq "author_za" || $sort eq "author_dsc" ) {
                 $sort_by .= "1=1003 >i ";
             }
             elsif ( $sort eq "popularity_asc" ) {
@@ -389,10 +389,10 @@ sub getRecords {
             elsif ( $sort eq "acqdate_dsc" ) {
                 $sort_by .= "1=32 >i ";
             }
-            elsif ( $sort eq "title_az" ) {
+            elsif ( $sort eq "title_az" || $sort eq "title_asc" ) {
                 $sort_by .= "1=4 <i ";
             }
-            elsif ( $sort eq "title_za" ) {
+            elsif ( $sort eq "title_za" || $sort eq "title_dsc" ) {
                 $sort_by .= "1=4 >i ";
             }
             else {
@@ -2286,7 +2286,7 @@ sub NZorder {
     # sort the hash and return the same structure as GetRecords (Zebra querying)
         my $result_hash;
         my $numbers = 0;
-        if ( $ordering eq 'author_za' ) {    # sort by author desc
+        if ( $ordering eq 'author_za' || $ordering eq 'author_dsc' ) {    # sort by author desc
             foreach my $key ( sort { $b cmp $a } ( keys %result ) ) {
                 $result_hash->{'RECORDS'}[ $numbers++ ] =
                   $result{$key}->as_usmarc();
-- 
1.5.6.5



More information about the Koha-patches mailing list