Adding the sitemap to a component through an external

Posted: 1 July 2009 in Components, External, Pages, Site map, SitePublisher, Sites, XSL
Tags: , , , , , ,

As part of your navigation, you probably will have to create your own component. Here’s a crude one that I made.

Content XML

<Data>
  <External>
    <Object Scope="local">com.interwoven.livesite.external.impl.LivesiteSiteMap</Object>
    <Method>getSiteMap</Method>
  </External>
</Data>

Appearance XSL

<xsl:template match="/">
    <div class="navigation"><xsl:apply-templates select="/site-map/segment/node" /></div>
</xsl:template>
<xsl:template match="node">
        <div>
            <xsl:attribute name="title"><xsl:value-of select="description" disable-output-escaping="yes" /></xsl:attribute>
            <xsl:choose>
                <xsl:when test="link/@type != ''">
                    <xsl:comment><!-- we have a query string to process --></xsl:comment>
                    <xsl:variable name="queryString"><xsl:for-each select="link/query-string/parameter">&amp;<xsl:value-of select="name" />=<xsl:value-of select="value" /></xsl:for-each></xsl:variable>
                    <a>
                        <xsl:attribute name="href"><xsl:choose>
                                <xsl:when test="link/@type = 'page'">/<xsl:value-of select="link/value" />.shtml</xsl:when>
                                <xsl:otherwise><xsl:value-of select="link/value" /></xsl:otherwise>
                            </xsl:choose><xsl:choose><xsl:when test="contains(link/value,'?')"><xsl:value-of select="$queryString" /></xsl:when><xsl:otherwise><xsl:value-of select="substring($queryString,2)" /></xsl:otherwise></xsl:choose>
                        </xsl:attribute>
                        <xsl:choose>
                            <xsl:when test="link/@target != ''">
                                <xsl:attribute name="target"><xsl:value-of select="link/@target" /></xsl:attribute>
                            </xsl:when>
                            <xsl:otherwise></xsl:otherwise>
                        </xsl:choose>
                        <xsl:value-of select="label" disable-output-escaping="yes" />
                        <xsl:comment><!-- unfortunately, we can't process the "preserve query string parameters" instruction in this stylesheet, as it will be used from the development side, not the delivery side --></xsl:comment>
                    </a>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="label" disable-output-escaping="yes" />
                </xsl:otherwise>
            </xsl:choose>
        </div>
        <div style="margin-left: 15px">
            <xsl:apply-templates select="node" />
        </div>
    </xsl:template>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s