Bug 34025: (QA follow-up) Fix subfield $t handling for 7XX contained works

When 7XX fields contain both name ($a) and title ($t) subfields,
the link should search for the title rather than the name.
This is important for contained works that reference titles
within larger works.

This patch updates both intranet and OPAC XSLT files to check
for the presence of subfield $t and use title search (ti,phr:)
instead of author search (au:) when $t is present.

Test plan:
1. Find or create a bibliographic record with 7XX fields containing both $a (name) and $t (title) subfields
   - For example: 700 $a Smith, John $t The Great Adventure
2. View the record detail page in both staff interface and OPAC
3. In the "Contained works" section, click on the link for the 7XX field entry
4. Verify the search is performed as a title search (ti,phr:"The Great Adventure") rather than author search (au:"Smith, John")
5. Confirm the search results show records matching the title from subfield $t
6. Test with records that have 7XX fields with only $a subfields to ensure they still search by author
7. Repeat testing for different 7XX field types (700, 710, 711)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 3c72e5d9c5)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2025-08-27 16:01:35 +01:00 committed by Jacob O'Mara
parent bc42d53477
commit 8160231758
No known key found for this signature in database
2 changed files with 36 additions and 14 deletions

View File

@ -716,16 +716,28 @@
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">
<xsl:text>/cgi-bin/koha/catalogue/search.pl?q=au:"</xsl:text>
<xsl:value-of
select="str:encode-uri(marc:subfield[@code='a'], true())" />
<xsl:text>"</xsl:text>
<xsl:if test="$AuthorLinkSortBy!='default'">
<xsl:text>&amp;sort_by=</xsl:text>
<xsl:value-of select="$AuthorLinkSortBy" />
<xsl:text>_</xsl:text>
<xsl:value-of select="$AuthorLinkSortOrder" />
</xsl:if>
<xsl:choose>
<!-- If there's a $t subfield, treat as a title search -->
<xsl:when test="marc:subfield[@code='t']">
<xsl:text>/cgi-bin/koha/catalogue/search.pl?q=ti,phr:"</xsl:text>
<xsl:value-of
select="str:encode-uri(marc:subfield[@code='t'], true())" />
<xsl:text>"</xsl:text>
</xsl:when>
<!-- Otherwise treat as an author search -->
<xsl:otherwise>
<xsl:text>/cgi-bin/koha/catalogue/search.pl?q=au:"</xsl:text>
<xsl:value-of
select="str:encode-uri(marc:subfield[@code='a'], true())" />
<xsl:text>"</xsl:text>
<xsl:if test="$AuthorLinkSortBy!='default'">
<xsl:text>&amp;sort_by=</xsl:text>
<xsl:value-of select="$AuthorLinkSortBy" />
<xsl:text>_</xsl:text>
<xsl:value-of select="$AuthorLinkSortOrder" />
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>

View File

@ -825,10 +825,20 @@
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">
<xsl:text>/cgi-bin/koha/opac-search.pl?q=au:"</xsl:text>
<xsl:value-of
select="str:encode-uri(marc:subfield[@code='a'], true())" />
<xsl:text>"</xsl:text>
<xsl:choose>
<!-- If there's a $t subfield, treat as a title search -->
<xsl:when test="marc:subfield[@code='t']">
<xsl:text>/cgi-bin/koha/opac-search.pl?q=ti,phr:"</xsl:text>
<xsl:value-of select="str:encode-uri(marc:subfield[@code='t'], true())" />
<xsl:text>"</xsl:text>
</xsl:when>
<!-- Otherwise treat as an author search -->
<xsl:otherwise>
<xsl:text>/cgi-bin/koha/opac-search.pl?q=au:"</xsl:text>
<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())" />
<xsl:text>"</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$AuthorLinkSortBy!='default'">
<xsl:text>&amp;sort_by=</xsl:text>
<xsl:value-of select="$AuthorLinkSortBy" />