Bug 39896 - System preference AuthorLinkSortBy is not working for UNIMARC or custom XSLT
Summary: System preference AuthorLinkSortBy is not working for UNIMARC or custom XSLT
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Marion Durand
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on: 33217
Blocks:
  Show dependency treegraph
 
Reported: 2025-05-14 10:00 UTC by Marion Durand
Modified: 2025-07-23 22:41 UTC (History)
2 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: Small patch
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 just 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:
25.11.00
Circulation function:


Attachments
Bug 39896: Add UNIMARC support for AuthorLinkSortBy (13.33 KB, patch)
2025-05-15 09:04 UTC, Marion Durand
Details | Diff | Splinter Review
Bug 39896: Add UNIMARC support for AuthorLinkSortBy (13.38 KB, patch)
2025-05-31 20:58 UTC, David Nind
Details | Diff | Splinter Review
Bug 39896: Add UNIMARC support for AuthorLinkSortBy (13.48 KB, patch)
2025-07-21 08:08 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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
Comment 9 Marcel de Rooy 2025-07-18 07:39:54 UTC
Just wondering here about:

-rw-r--r-- 1 root         root         107578 Jul 15 16:07 MARC21slim2intranetDetail.xsl
-rw-r--r-- 1 root         root          55899 Jun 11 14:04 MARC21slim2intranetResults.xsl

-rw-r--r-- 1 root         root          21525 Jul 18 09:29 UNIMARCslim2intranetDetail.xsl
-rw-r--r-- 1 root         root           3304 Jun 11 14:04 UNIMARCslim2intranetResults.xsl

What is actually the current status of UNIMARCslim2intranetResults.xsl ? It is adjusted in MARC21 for the AuthorLinkSort stuff too..
Comment 10 Marcel de Rooy 2025-07-18 07:50:35 UTC
Although the code looks good to me, I would appreciate a response about the current status of using XSLT for OPAC and intranet on UNIMARC installs.
Comment 11 Marion Durand 2025-07-18 14:48:16 UTC
(In reply to Marcel de Rooy from comment #10)
> Although the code looks good to me, I would appreciate a response about the
> current status of using XSLT for OPAC and intranet on UNIMARC installs.

I'm not sure to understand your question, we often use XSLT in UNIMARC installation. Sometimes with community file, sometimes with custom file.

This patch adjusted the following files to add support for the syspref in default UNIMARC XSLT.
 prog/en/xslt/UNIMARCslim2intranetDetail.xsl
 prog/en/xslt/UNIMARCslimUtils.xsl
 bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl
 bootstrap/en/xslt/UNIMARCslimUtils.xsl

(plus /en/modules/admin/preferences/searching.pref to add a hint in the syspref for custom file).

I did not updated the following files as the author search link is not present in the first place (so no need to add parameters to this link)
prog/en/xslt/UNIMARCslim2intranetResults.xsl
bootstrap/en/xslt/UNIMARCslim2OPACResults.xsl
Comment 12 Marcel de Rooy 2025-07-21 07:06:48 UTC
(In reply to Marion Durand from comment #11)
> (In reply to Marcel de Rooy from comment #10)
> > Although the code looks good to me, I would appreciate a response about the
> > current status of using XSLT for OPAC and intranet on UNIMARC installs.
> 
> I'm not sure to understand your question, we often use XSLT in UNIMARC
> installation. Sometimes with community file, sometimes with custom file.

Looking at the UNIMARC community files, I wonder why they are so small (as compared to their MARC21 counterparts). Are they actually used somewhere, or generally replaced by customization?

I listed staff above, here is OPAC:
-rw-r--r-- 1 root         root         123416 Jul 15 16:07 MARC21slim2OPACDetail.xsl
-rw-r--r-- 1 root         root          86887 Jul 15 16:07 MARC21slim2OPACResults.xsl
-rw-r--r-- 1 root         root          40052 Jul 15 16:07 MARC21slimUtils.xsl
-rw-r--r-- 1 root         root          25784 Jul 18 09:51 UNIMARCslim2OPACDetail.xsl
-rw-r--r-- 1 root         root          19112 Jun 11 14:04 UNIMARCslim2OPACResults.xsl
-rw-r--r-- 1 root         root          20546 Jul 18 09:51 UNIMARCslimUtils.xsl

For instance OPACDetail is 5x smaller.
Comment 13 Marion Durand 2025-07-21 07:21:17 UTC
(In reply to Marcel de Rooy from comment #12)
> (In reply to Marion Durand from comment #11)
> > (In reply to Marcel de Rooy from comment #10)
> > > Although the code looks good to me, I would appreciate a response about the
> > > current status of using XSLT for OPAC and intranet on UNIMARC installs.
> > 
> > I'm not sure to understand your question, we often use XSLT in UNIMARC
> > installation. Sometimes with community file, sometimes with custom file.
> 
> Looking at the UNIMARC community files, I wonder why they are so small (as
> compared to their MARC21 counterparts). Are they actually used somewhere, or
> generally replaced by customization?
> 
> I listed staff above, here is OPAC:
> -rw-r--r-- 1 root         root         123416 Jul 15 16:07
> MARC21slim2OPACDetail.xsl
> -rw-r--r-- 1 root         root          86887 Jul 15 16:07
> MARC21slim2OPACResults.xsl
> -rw-r--r-- 1 root         root          40052 Jul 15 16:07
> MARC21slimUtils.xsl
> -rw-r--r-- 1 root         root          25784 Jul 18 09:51
> UNIMARCslim2OPACDetail.xsl
> -rw-r--r-- 1 root         root          19112 Jun 11 14:04
> UNIMARCslim2OPACResults.xsl
> -rw-r--r-- 1 root         root          20546 Jul 18 09:51
> UNIMARCslimUtils.xsl
> 
> For instance OPACDetail is 5x smaller.

They are used but, as it was the case here, many functionalities are added in MARC21 but not in UNIMARC. These files might also be simpler with less information (or link) displayed.
Comment 14 Marcel de Rooy 2025-07-21 08:08:22 UTC
Created attachment 184424 [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>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 15 Marcel de Rooy 2025-07-21 08:11:44 UTC
Thx for your feedback. Passing QA.

Just wondering if
+            - "<br /><strong>NOTE:</strong> If you are using custom XSLT you need to make sure the system preference check is implemented."
this is clear enough. But can be improved later.
What a dev probably needs to do, is pass those pref values to the relevant template (showAuthor or tag_7xx etc.)
Comment 16 Lucas Gass (lukeg) 2025-07-23 22:41:05 UTC
Nice work everyone!

Pushed to main for 25.11