Bug 39896

Summary: System preference AuthorLinkSortBy is not working for UNIMARC or custom XSLT
Product: Koha Reporter: Marion Durand <marion.durand>
Component: SearchingAssignee: Marion Durand <marion.durand>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: david
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
This fixes the default UNIMARC XSLT files so that the AuthorLinkSortBy and AuthorLinkSortOrder system preferences now work with UNIMARC, not jsut MARC21. A note was also added to the system preference for those that use custom XSLT (for OPACXSLTDetailsDisplay, OPACXSLTResultsDisplay, XSLTDetailsDisplay, and XSLTResultsDisplay) - they need to update their templates to support these features for both MARC21 and UNIMARC. (These preferences were added in Koha 23.11 by Bug 33217 - Allow different default sorting when click author links, but only the default XSLT files for MARC21 were updated.)
Version(s) released in:
Circulation function:
Bug Depends on: 33217    
Bug Blocks:    
Attachments: Bug 39896: Add UNIMARC support for AuthorLinkSortBy
Bug 39896: Add UNIMARC support for AuthorLinkSortBy

Description Marion Durand 2025-05-14 10:00:43 UTC
The syspref AuthorLinkSortBy and AuthorLinkSortOrder depend on code in XSLT files.

Currently, the code is only present in the default MARC21 files but it is not present in any UNIMARC files.

Plus, if a library uses customs XSLT files (with syspref OPACXSLTDetailsDisplay, OPACXSLTResultsDisplay, XSLTDetailsDisplay, or XSLTResultsDisplay) they will not be able to use this functionality (unless they also updated their files but they have no way to know they need to do that). 
This is inevitable and is okay, but I think we should mention somewhere that these syspref depend on XSLT.
Comment 1 Katrin Fischer 2025-05-14 15:25:39 UTC
As you write it cannot really be changed unless they implement it, which they could. Maybe a hint: If you are using custom XSLT you need to make sure the system preference check is implemented. ?
Comment 2 Marion Durand 2025-05-15 07:16:54 UTC
I think there is two part (maybe I should have files tow bug ?) : default UNIMARC files (provided in Koha code) and libraries using custom XSLT files.

I will try to provide a patch for the default UNIMARC files.

(In reply to Katrin Fischer from comment #1)
> As you write it cannot really be changed unless they implement it, which
> they could. Maybe a hint: If you are using custom XSLT you need to make sure
> the system preference check is implemented. ?
Yes, I think we could add a hint either on the syspref description or in the manuel. It would help understand why the syspref has no effect in certains cases.
Comment 3 Katrin Fischer 2025-05-15 07:26:51 UTC
Hi Marion, if you want to split, that's fine, but I think a textual hint would be OK as part of the UNIMARC patch as well being low risk.
Comment 4 Marion Durand 2025-05-15 07:35:12 UTC
Hi Katrin, 
If it can be done with the UNIMARC patch, I can do that too.
Thank you for your help :)
Comment 5 Marion Durand 2025-05-15 09:04:34 UTC
Created attachment 182479 [details] [review]
Bug 39896: Add UNIMARC support for AuthorLinkSortBy

This patch add support for AuthorLinkSortBy and AuthorLinkSortOrder in
the default UNIMARC XSLT files.

The description of the syspref is also slighly updated to hint users of
custom XSLT file about the need to update their template.

To test:
0. On a UNIMARC database
1. Set AuthorLinkSortBy to 'title' and AuthorLinkSortORder to
   'descending'
2. On the intranet and OPAC, search for an author you have multiple
   titles from and click on a result
3. Click on a link one a name for an author
4. Note a new search is performed, sorted by field from defaultSortField
   preference and not by title descending
5. Apply the patch
6. restart_all
7. Check that the syspref description now include a note about custom
   XSLT files
8. Repeat step 2 and 3
9. Note a new search is performed, sorted by title descending
10. Test other values - confirm links are updated in both staff and opac
Comment 6 David Nind 2025-05-22 22:56:36 UTC
Added assignee.
Comment 7 David Nind 2025-05-31 20:58:30 UTC
Created attachment 182884 [details] [review]
Bug 39896: Add UNIMARC support for AuthorLinkSortBy

This patch add support for AuthorLinkSortBy and AuthorLinkSortOrder in
the default UNIMARC XSLT files.

The description of the syspref is also slighly updated to hint users of
custom XSLT file about the need to update their template.

To test:
0. On a UNIMARC database
1. Set AuthorLinkSortBy to 'title' and AuthorLinkSortORder to
   'descending'
2. On the intranet and OPAC, search for an author you have multiple
   titles from and click on a result
3. Click on a link one a name for an author
4. Note a new search is performed, sorted by field from defaultSortField
   preference and not by title descending
5. Apply the patch
6. restart_all
7. Check that the syspref description now include a note about custom
   XSLT files
8. Repeat step 2 and 3
9. Note a new search is performed, sorted by title descending
10. Test other values - confirm links are updated in both staff and opac

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 David Nind 2025-05-31 21:14:02 UTC
Testing notes (using KTD):

1. To start up KTD with UNIMARC, edit your .env file and set KOHA_MARC_FLAVOUR=unimarc

2. An author with multiple records: Louis Gardel