From 89196410197ba118e935fb7068e93081a45fb44a Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 13 Mar 2023 19:45:49 +0000 Subject: [PATCH] Bug 33217: Allow specifiying sort field and order for authro links When using the facets for author, i.e. limiting a search, it makes sense to preserve the default sort order for the results (relevance, etc) When clicking on an author to search the catalog for all works by an author, it would be nice to be able to optionally specify sorting for the listing - i.e. publication date, or title This patch adds two new system preferences: AuthorLinkSortBy AuthorLinkSortOrder To test: 1 - Do a search in intranet and staff for 'austen' or an author you have multiple titles from 2 - Click the linked name 3 - Note a new search is performed, sorted by field from defaultSortField preference 4 - Apply patch, updatedatabase, restart_all 5 - Ensure nothing has changed by searching again 6 - Set AuthorLinkSortBy to 'date of publication' and AuthorLinkSortORder to asc 7 - Search again, comfirm links obey sorting specific above 8 - Test other values - confirm links are updated in both staff/opac and results/details --- C4/XSLT.pm | 3 +- installer/data/mysql/mandatory/sysprefs.sql | 2 ++ .../modules/admin/preferences/searching.pref | 17 ++++++++++ .../en/xslt/MARC21slim2intranetDetail.xsl | 31 +++++++++++++++++-- .../en/xslt/MARC21slim2intranetResults.xsl | 25 +++++++++++++-- .../en/xslt/MARC21slim2OPACDetail.xsl | 31 +++++++++++++++++-- .../en/xslt/MARC21slim2OPACResults.xsl | 25 +++++++++++++-- 7 files changed, 125 insertions(+), 9 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 21d270e3df..a2c9cf6e5b 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -98,7 +98,8 @@ sub get_xslt_sysprefs { OPACResultsLibrary OPACShowOpenURL OpenURLResolverURL OpenURLImageLocation OPACResultsMaxItems OPACResultsMaxItemsUnavailable OPACResultsUnavailableGroupingBy - OpenURLText OPACShowMusicalInscripts OPACPlayMusicalInscripts / ) + OpenURLText OPACShowMusicalInscripts OPACPlayMusicalInscripts + AuthorLinkSortBy AuthorLinkSortOrder / ) { my $sp = C4::Context->preference( $syspref ); next unless defined($sp); diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index b12f1ce170..3752a20be2 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -73,6 +73,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AuthoritySeparator','--','10','Used to separate a list of authorities in a display. Usually --','free'), ('AuthorityXSLTOpacResultsDisplay','','','Enable XSL stylesheet control over authority results page in the OPAC','Free'), ('AuthorityXSLTResultsDisplay','','','Enable XSL stylesheet control over authority results page display on intranet','Free'), +('AuthorLinkSortBy','default','call_number|pubdate|acqdate|title','Specify the default field used for sorting when click author links','Choice'), +('AuthorLinkSortOrder','asc','asc|dsc|az|za','Specify the default sort order for author links','Choice'), ('AuthSuccessLog','0',NULL,'If enabled, log successful authentications','YesNo'), ('autoBarcode','OFF','incremental|annual|hbyymmincr|EAN13|OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch','Choice'), ('autoControlNumber','OFF','biblionumber|OFF','Used to autogenerate a Control Number: biblionumber will be as biblionumber, OFF will leave the field as it is;','Choice'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index 93084ee641..2ef55887dd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -174,6 +174,23 @@ Searching: dsc: descending. az: from A to Z. za: from Z to A. + - + - By default, sort search results from author links by + - pref: AuthorLinkSortBy + default: default + choices: + default: obey default sort field and order specified in defaultSortField or OPACdefaultSortField + call_number: call number + pubdate: date of publication + acqdate: date added + title: title + - ',' + - pref: AuthorLinkSortOrder + choices: + asc: ascending. + dsc: descending. + az: from A to Z. + za: from Z to A. - - When limiting search results with a library or library group, limit by the item's - pref: SearchLimitLibrary diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl index c5fd064e63..10d64dfc66 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl @@ -24,6 +24,8 @@ ,complete-subfield + + @@ -155,12 +157,16 @@ + + + + @@ -1493,6 +1499,8 @@ + +
@@ -1506,10 +1514,29 @@ - /cgi-bin/koha/catalogue/search.pl?q=an: + + /cgi-bin/koha/catalogue/search.pl?q=an: + + + &sortby= + + _ + + + - /cgi-bin/koha/catalogue/search.pl?q=au:"" + + /cgi-bin/koha/catalogue/search.pl?q=au:" + + " + + &sortby= + + _ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl index fa94894870..8998f62aaf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl @@ -24,6 +24,8 @@ + + @@ -350,10 +352,29 @@ - /cgi-bin/koha/catalogue/search.pl?q=an: + + /cgi-bin/koha/catalogue/search.pl?q=an: + + + &sortby= + + _ + + + - /cgi-bin/koha/catalogue/search.pl?q=au:"" + + /cgi-bin/koha/catalogue/search.pl?q=au:" + + " + + &sortby= + + _ + + + diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl index 34a6e0bbf7..f9c6ffae36 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl @@ -26,6 +26,8 @@ ,complete-subfield + + @@ -174,6 +176,8 @@ + + @@ -182,6 +186,8 @@ + + @@ -1708,6 +1714,8 @@ + + @@ -1737,10 +1745,29 @@ - /cgi-bin/koha/opac-search.pl?q=an:"" + + /cgi-bin/koha/opac-search.pl?q=an: + + + &sortby= + + _ + + + - /cgi-bin/koha/opac-search.pl?q=au:"" + + /cgi-bin/koha/opac-search.pl?q=au:" + + " + + &sortby= + + _ + + + contributors diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl index 9e7a16a2bb..765cbb9013 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl @@ -28,6 +28,8 @@ + + @@ -525,10 +527,29 @@ - /cgi-bin/koha/opac-search.pl?q=an: + + /cgi-bin/koha/opac-search.pl?q=an: + + + &sortby= + + _ + + + - /cgi-bin/koha/opac-search.pl?q=au:"" + + /cgi-bin/koha/opac-search.pl?q=au:" + + " + + &sortby= + + _ + + + -- 2.30.2