diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt index 5bed02084e..8267123aa5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -462,6 +462,8 @@ [% END %] [% IF shelf.sortfield == "copyrightdate" %] + [% ELSIF shelf.sortfield == "publicationyear" %] + [% ELSE %] [% END %] diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index 760e228dbd..f51f7d064b 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -123,7 +123,11 @@ if ( $op eq 'add_form' ) { if ($shelf) { $op = $referer; my $sortfield = $query->param('sortfield'); - $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded ); + $sortfield = 'title' + unless grep { $_ eq $sortfield } qw( title author copyrightdate publicationyear itemcallnumber dateadded ); + if ( $sortfield == 'copyrightdate' and C4::Context->preference('marcflavour') == 'UNIMARC' ) { + $sortfield = 'publicationyear'; + } if ( $shelf->can_be_managed($loggedinuser) ) { $shelf->shelfname( scalar $query->param('shelfname') ); $shelf->sortfield($sortfield); @@ -291,7 +295,11 @@ if ( $op eq 'view' ) { || $shelf->sortfield || 'title'; # Passed in sorting overrides default sorting $sortfield = 'title' - unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded ); + unless grep { $_ eq $sortfield } + qw( title author copyrightdate publicationyear itemcallnumber dateadded ); + if ( $sortfield == 'copyrightdate' and C4::Context->preference('marcflavour') == 'UNIMARC' ) { + $sortfield = 'publicationyear'; + } my $direction = $query->param('direction') || 'asc'; $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc'; my $rows;