Bug 8948: Display MARC 787 relationship field
authorNick Clemens <nick@bywatersolutions.com>
Fri, 28 Oct 2022 16:38:22 +0000 (16:38 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Thu, 10 Nov 2022 16:56:39 +0000 (13:56 -0300)
This field is defined similar to 775, as a related work:
https://www.loc.gov/marc/bibliographic/bd787.html

This patch adds a display of this field, linking to the referenced record as the 775 does

It also tests for 580 field, and displays the text there if present, using the 787 a and t subfields otherwise

To test:
1 - Edit the default framework to make 787atw and 580a visible in editor
2 - Add a 787 to a record:
    $tThe ideas behind the chess openings
    $aFine, Reuben<
    $w2470231
3 - Confirm there is no display
4 - Apply patch / restart all
5 - 'Other related works' now shows
6 - Link should be using title of record
7 - Set system preference UseControlNumber to Use
8 - Reload details, link should now use control number
9 - Add a 580 to the record:
    $a This is a friendly work to this one
10 - Confirm the text of the link now displays before the link
11 - Add a second 580, confirm it displays as well
   - there is no seperator as each should end with a period or other punctuation according to MARC
   - there is a dpan with a class surrounding each so styling can be added as desired
12 - Add a second 787
   - confirm seperator present and wrapped in a span with a class
   - confirm each 787 is shown with a span/class for styling

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl

index acaf38a..c3dff33 100644 (file)
             </xsl:for-each>
         </xsl:if>
 
+        <!--  787 Other Relationship Entry  -->
+        <xsl:if test="marc:datafield[@tag=787]">
+        <span class="results_summary other_relationship_entry"><span class="label">Other related works: </span>
+        <xsl:for-each select="marc:datafield[@tag=580]">
+            <span class="linking_complexity_note">
+                <xsl:call-template name="subfieldSelect">
+                    <xsl:with-param name="codes">a</xsl:with-param>
+                </xsl:call-template>
+                <xsl:text> </xsl:text>
+            </span>
+        </xsl:for-each>
+        <xsl:for-each select="marc:datafield[@tag=787]">
+            <span class="other_relationship_entry">
+                <xsl:variable name="f787">
+                    <xsl:call-template name="chopPunctuation"><xsl:with-param name="chopString"><xsl:call-template name="subfieldSelect">
+                    <xsl:with-param name="codes">a_t</xsl:with-param>
+                    </xsl:call-template></xsl:with-param></xsl:call-template>
+                </xsl:variable>
+                <xsl:if test="marc:subfield[@code='i']">
+                    <xsl:call-template name="subfieldSelect">
+                        <xsl:with-param name="codes">i</xsl:with-param>
+                    </xsl:call-template>
+                    <xsl:text>: </xsl:text>
+                </xsl:if>
+                <xsl:choose>
+                <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
+                    <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
+                        <xsl:value-of select="$f787"/>
+                    </a>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:variable name="relation_query">
+                        <xsl:text>ti,phr:(</xsl:text>
+                        <xsl:call-template name="quote_search_term">
+                            <xsl:with-param name="term"><xsl:value-of select="marc:subfield[@code='t']"/></xsl:with-param>
+                        </xsl:call-template>
+                        <xsl:text>)</xsl:text>
+                        <xsl:if test="marc:subfield[@code='a']">
+                            <xsl:text> AND au:(</xsl:text>
+                            <xsl:call-template name="quote_search_term">
+                                <xsl:with-param name="term">
+                                    <xsl:value-of select="marc:subfield[@code='a']"/>
+                                </xsl:with-param>
+                            </xsl:call-template>
+                            <xsl:text>)</xsl:text>
+                        </xsl:if>
+                    </xsl:variable>
+                    <a>
+                    <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="str:encode-uri($relation_query, true())" />
+                    </xsl:attribute>
+                        <xsl:value-of select="$f787"/>
+                    </a>
+                </xsl:otherwise>
+                </xsl:choose>
+                <xsl:choose>
+                    <xsl:when test="position()=last()"></xsl:when>
+                    <xsl:otherwise><span class="separator"><xsl:text>; </xsl:text></span></xsl:otherwise>
+                </xsl:choose>
+            </span>
+        </xsl:for-each>
+        </span>
+        </xsl:if>
+
         <!-- Indicate if record is suppressed in OPAC -->
         <xsl:choose>
             <xsl:when test="$OpacSuppression = 1 and marc:datafield[@tag=942][marc:subfield[@code='n'] = '1']">