From 383c451eb895e142d8dc22275eeafac06c25b7b6 Mon Sep 17 00:00:00 2001 From: Garry Collum Date: Tue, 23 Jun 2009 21:23:15 -0400 Subject: [PATCH] Bug 3229: Fixes sort-by feature for jquery tablesorter in lists. Content-Type: text/plain; charset="utf-8" This patch adds some variables for the sortfield that are passed through the URL so that the sort-by feature works when the jquery tablesorter is used for a list of titles in opac-shelves.tmpl. --- C4/VirtualShelves/Page.pm | 13 ++++++++++++- koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc | 4 ++-- .../opac-tmpl/prog/en/modules/opac-shelves.tmpl | 16 ++++++++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index 99d1f5d..999692c 100644 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -170,6 +170,15 @@ SWITCH: { #check that the user can view the shelf if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) { my $items; + my $authorsort; + my $copyrightsort; + my $sortfield = ($query->param('sortfield') ? $query->param('sortfield') : 'title'); + if ($sortfield eq 'author') { + $authorsort = 'author'; + } + if ($sortfield eq 'copyrightdate'){ + $copyrightsort = 'copyrightdate'; + } ($items, $totitems) = GetShelfContents($shelfnumber, $shelflimit, $shelfoffset); for my $this_item (@$items) { # the virtualshelfcontents table does not store these columns nor are they retrieved from the items @@ -188,6 +197,8 @@ SWITCH: { shelfname => $shelflist->{$shelfnumber}->{'shelfname'} || $privshelflist->{$shelfnumber}->{'shelfname'}, shelfnumber => $shelfnumber, viewshelf => $shelfnumber, + authorsort => $authorsort, + copyrightsort => $copyrightsort, manageshelf => $manageshelf, itemsloop => $items, ); @@ -291,7 +302,7 @@ foreach my $element (sort { lc($shelflist->{$a}->{'shelfname'}) cmp lc($shelflis my $url = $type eq 'opac' ? "/cgi-bin/koha/opac-shelves.pl" : "/cgi-bin/koha/virtualshelves/shelves.pl"; my %qhash = (); -foreach (qw(display viewshelf)) { +foreach (qw(display viewshelf sortfield)) { $qhash{$_} = $query->param($_) if $query->param($_); } (scalar keys %qhash) and $url .= '?' . join '&', map {"$_=$qhash{$_}"} keys %qhash; diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc index 2d4e313..cd258f7 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc @@ -103,7 +103,7 @@ @@ -120,7 +120,7 @@ diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl index c15bdc3..a1dda46 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl @@ -77,10 +77,22 @@ $(function() { $("#listcontents").tablesorter({ widgets : ['zebra'], + + sortList: [[2,0]], + + sortList: [[3,1]], + sortList: [[1,0]], + headers: { 0: { sorter: false },1:{sorter: 'articles'} + + sortList: [[1,0]], + + sortList: [[2,1]], + sortList: [[0,0]], + headers: { 0:{sorter:'articles'} } @@ -338,7 +350,7 @@ $(document).ready(function(){ - "> + &sortfield="> item(s) @@ -406,7 +418,7 @@ $(document).ready(function(){ - "> + &sortfield="> item(s) -- 1.5.6.5