From 45069c1ca4191e9745875197c6b010c6fa480d4c Mon Sep 17 00:00:00 2001 From: Garry Collum Date: Tue, 23 Jun 2009 21:42:05 -0400 Subject: [PATCH] Bug 3229: Fixes sort-by feature for jquery tablesorter in lists. 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. Signed-off-by: Galen Charlton --- C4/VirtualShelves/Page.pm | 13 ++++++++++++- .../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 99d1f5d4d2..999692cfce 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 2d4e313c3b..cd258f7204 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 c15bdc3803..a1dda46cfc 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) -- 2.39.5