From 303aa7df2c0b1ce0807f69b8d83f4eb4003086d8 Mon Sep 17 00:00:00 2001
From: Fridolin Somers <fridolin.somers@biblibre.com>
Date: Fri, 14 May 2021 16:02:57 +0200
Subject: [PATCH] Bug 27850: Search link for 260 a and c in MARC21 XSLT OPAC
 display

In MARC21 XSLT OPAC display, 260$b is a search link on 'Provider'.
$a and $c also have a search field, we can create search links.

Test plan:
1) Create 2 records with same 260 : two $a, one $b, two $c
2) Use XSLT display in OPAC
2) Look at first record details page in OPAC
3) Click on a $a link => you see both records
4) Click on a $c link => you see both records

https://bugs.koha-community.org/show_bug.cgi?id=27850

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 .../en/xslt/MARC21slim2OPACDetail.xsl         | 34 ++++++++++++++-----
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl
index 0110d22215..1704004ea1 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl
@@ -326,13 +326,17 @@
              <span class="results_summary publisher"><span class="label">Publication details: </span>
                  <xsl:for-each select="marc:datafield[@tag=260]">
                      <span property="publisher" typeof="Organization">
-                     <xsl:if test="marc:subfield[@code='a']">
-                        <span class="publisher_place" property="location">
-                            <xsl:call-template name="subfieldSelect">
-                                <xsl:with-param name="codes">a</xsl:with-param>
-                            </xsl:call-template>
-                        </span>
-                     </xsl:if>
+                         <xsl:for-each select="marc:subfield[@code='a']">
+                            <span class="publisher_place" property="location">
+                                <a>
+                                    <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=pl:"<xsl:value-of select="str:encode-uri(., true())"/>"</xsl:attribute>
+                                    <xsl:value-of select="."/>
+                                </a>
+                            </span>
+                            <xsl:if test="position() != last()">
+                                <xsl:text> </xsl:text>
+                            </xsl:if>
+                         </xsl:for-each>
                      <xsl:text> </xsl:text>
                      <xsl:if test="marc:subfield[@code='b']">
                         <span property="name" class="publisher_name">
@@ -345,12 +349,24 @@
                      </xsl:if>
                      </span>
                      <xsl:text> </xsl:text>
-                     <xsl:if test="marc:subfield[@code='c' or @code='g']">
+                     <xsl:for-each select="marc:subfield[@code='c']">
+                         <span property="datePublished" class="publisher_date">
+                             <a>
+                                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=copydate:"<xsl:value-of select="str:encode-uri(., true())"/>"</xsl:attribute>
+                                 <xsl:value-of select="."/>
+                             </a>
+                             <xsl:if test="position() != last()">
+                                 <xsl:text> </xsl:text>
+                             </xsl:if>
+                         </span>
+                     </xsl:for-each>
+                     <xsl:text> </xsl:text>
+                     <xsl:if test="marc:subfield[@code='g']">
                         <span property="datePublished" class="publisher_date">
                            <xsl:call-template name="chopPunctuation">
                                <xsl:with-param name="chopString">
                                     <xsl:call-template name="subfieldSelect">
-                                        <xsl:with-param name="codes">cg</xsl:with-param>
+                                        <xsl:with-param name="codes">g</xsl:with-param>
                                     </xsl:call-template>
                                 </xsl:with-param>
                             </xsl:call-template>
-- 
2.20.1