From: Ian Walls <ian.walls@bywatersolutions.com> To: koha-patches@lists.koha-community.org Cc: Jared Camins-Esakov <jcamins@bywatersolutions.com>, Ian Walls <ian.walls@bywatersolutions.com> Subject: [PATCH] Bug 6154: Default sorting by title doesn't work Date: Sun, 10 Apr 2011 17:28:05 -0400 Message-Id: <1302470885-1801-1-git-send-email-ian.walls@bywatersolutions.com> X-Mailer: git-send-email 1.5.6.5 Content-Type: text/plain; charset="utf-8" From: Jared Camins-Esakov <jcamins@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@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