Make author and subject links clickable (Manakin)

From DSpace Wiki

Jump to: navigation, search


This page assumes that you are working from DIM rather than MODS. The technique should be transferable, however, as it relies on browse-by-author and browse-by-subject pages having predictable URLs.

This page walks you through creating author links. Subject links employ the same technique.

[edit] STEP 1: Encode all URLs in Manakin

This is done so that special characters in author names don't break browsers when used in URLs. In your main sitemap.xmap file, add the following just under the root <sitemap:xmap> element:

<map:components>
  <map:transformers>
       <map:transformer name="encodeURL" src="org.apache.cocoon.transformation.EncodeURLTransformer"/>
  </map:transformers>
</map:components>

Then, between Steps 2 and 3, add the following:

<map:transform type="encodeURL"/>

[edit] STEP 2: Copy templates into your theme

The XSLT that creates author listings is in themes/dri2xhtml/DS-METS-1.0-DIM.xsl. Copy two <xsl:template> blocks into your theme's XSLT:

  • the one with name="itemSummaryList_DS-METS-1.0-DIM" (this governs authors on browse lists)
  • the one with name="itemSummaryView_DS-METS-1.0-DIM" (this governs authors on item pages)

[edit] STEP 3: Alter authors to add links

The existing code looks like this in both locations:

<span class="author">
    <xsl:choose>
        <xsl:when test="$data/dim:field[@element='contributor'][@qualifier='author']">
            <xsl:for-each select="$data/dim:field[@element='contributor'][@qualifier='author']">
                <xsl:copy-of select="."/>
                <xsl:if test="count(following-sibling::dim:field[@element='contributor'][@qualifier='author']) != 0">
                    <xsl:text>; </xsl:text>
                </xsl:if>
            </xsl:for-each>
        </xsl:when>
        <xsl:when test="$data/dim:field[@element='creator']">
            <xsl:for-each select="$data/dim:field[@element='creator']">
                <xsl:copy-of select="."/>
                <xsl:if test="count(following-sibling::dim:field[@element='creator']) != 0">
                    <xsl:text>; </xsl:text>
                </xsl:if>
            </xsl:for-each>
        </xsl:when>
        <xsl:when test="$data/dim:field[@element='contributor']">
            <xsl:for-each select="$data/dim:field[@element='contributor']">
                <xsl:copy-of select="."/>
                <xsl:if test="count(following-sibling::dim:field[@element='contributor']) != 0">
                    <xsl:text>; </xsl:text>
                </xsl:if>
            </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
            <i18n:text>xmlui.dri2xhtml.METS-1.0.no-author</i18n:text>
        </xsl:otherwise>
    </xsl:choose>
</span>

Inside EACH of the <xsl:for-each> blocks, add a link:

<xsl:for-each select="$data/dim:field[@element='contributor'][@qualifier='author']">
    <a>
        <xsl:attribute name="href">
            <xsl:value-of
                select="concat($context-path,'/browse-author-items?author=')"/>
            <xsl:copy-of select="."/>
        </xsl:attribute>
        <xsl:value-of select="text()"/>
    </a>
    <xsl:if test="count(following-sibling::dim:field[@element='contributor'][@qualifier='author']) != 0">
        <xsl:text>; </xsl:text>
    </xsl:if>
</xsl:for-each>
Personal tools