From 4b71a85e13ce88d1e6a84be35d0be6d3b27eecbe 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 Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- 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 6a10206359..aa0684cc35 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 ContentWarningField / ) + OpenURLText OPACShowMusicalInscripts OPACPlayMusicalInscripts ContentWarningField + 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 241b43b502..3e6715120d 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -77,6 +77,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AuthorityXSLTOpacDetailsDisplay','','','Enable XSL stylesheet control over authority details page in the OPAC','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 4428d3f6ca..ef97b98579 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 @@ + + + + @@ -1608,6 +1614,8 @@ + +
@@ -1621,10 +1629,29 @@ - /cgi-bin/koha/catalogue/search.pl?q=an: + + /cgi-bin/koha/catalogue/search.pl?q=an: + + + &sort_by= + + _ + + + - /cgi-bin/koha/catalogue/search.pl?q=au:"" + + /cgi-bin/koha/catalogue/search.pl?q=au:" + + " + + &sort_by= + + _ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl index 5dbf57d1e7..ac1a7c54aa 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: + + + &sort_by= + + _ + + + - /cgi-bin/koha/catalogue/search.pl?q=au:"" + + /cgi-bin/koha/catalogue/search.pl?q=au:" + + " + + &sort_by= + + _ + + + diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl index 047d56eae1..31af6ee9a4 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 @@ + + @@ -1802,6 +1808,8 @@ + + @@ -1831,10 +1839,29 @@ - /cgi-bin/koha/opac-search.pl?q=an:"" + + /cgi-bin/koha/opac-search.pl?q=an: + + + &sort_by= + + _ + + + - /cgi-bin/koha/opac-search.pl?q=au:"" + + /cgi-bin/koha/opac-search.pl?q=au:" + + " + + &sort_by= + + _ + + + contributors diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl index 0c2b499049..57d8547cc9 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: + + + &sort_by= + + _ + + + - /cgi-bin/koha/opac-search.pl?q=au:"" + + /cgi-bin/koha/opac-search.pl?q=au:" + + " + + &sort_by= + + _ + + + -- 2.39.5