forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Koberg" <...@koberg.com>
Subject Re: Forrest new style
Date Thu, 06 Jun 2002 13:50:47 GMT
Hi again, I just noticed I pasted XSLT for a snail trail when you were
talking about pagination. Don't know what I was thinking... Anyway, I know
you are not looking for this, but I just wanted to post up the XSLT I use
for pagination. Hopefully this may be useful to someone.

<xsl:template match="page" mode="pager">
    <xsl:if test="position()=1">
        <xsl:apply-templates select="$active_nodeset" mode="pager_prev">
            <xsl:with-param name="first_id" select="@id"/>
        </xsl:apply-templates>
        <xsl:text>  </xsl:text>
    </xsl:if>
    <xsl:choose>
        <xsl:when test="@id=$active_nodeset/@id">
            <span class="pagerCurrentPage">
                <xsl:value-of select="position()"/>
            </span>
        </xsl:when>
        <xsl:otherwise>
            <xsl:variable name="_href">
                <xsl:for-each select="ancestor::folder">
                    <xsl:text>/</xsl:text>
                    <xsl:value-of select="@name"/>
                </xsl:for-each>
                <xsl:text>/</xsl:text>
                <xsl:value-of select="translate(@label, ' ', '_')"/>
                <xsl:value-of select="@file_ext"/>
            </xsl:variable>

            <a href="{$_href}">

                 <xsl:value-of select="position()"/>

             </a>

        </xsl:otherwise>
    </xsl:choose>
    <xsl:text> </xsl:text>
    <xsl:if test="position()=last()">
        <xsl:variable name="following_page" select="key('site_config_key',
following-sibling::page[@id=$active_nodeset/@id]/@id)"/>
        <xsl:text> &#187; </xsl:text>
        <xsl:apply-templates select="$active_nodeset" mode="pager_next">
            <xsl:with-param name="last_id" select="@id"/>
        </xsl:apply-templates>
    </xsl:if>
</xsl:template>

<xsl:template match="page" mode="pager_prev">
    <xsl:param name="first_id"/>
   <xsl:choose>
        <xsl:when test="not(@id=$first_id)">
            <xsl:variable name="_href">
                <xsl:for-each select="ancestor::folder">
                    <xsl:text>/</xsl:text>
                    <xsl:value-of select="@name"/>
                </xsl:for-each>
                <xsl:text>/</xsl:text>
                <xsl:variable name="prev_label"
select="preceding-sibling::page[1]/@label"/>
                <xsl:value-of select="translate($prev_label, ' ', '_')"/>
                <xsl:value-of select="@file_ext"/>
            </xsl:variable>

            <a href="{$_href}">
                &#171; prev</a>

            <xsl:text> </xsl:text>
        </xsl:when>
        <xsl:otherwise>
            <xsl:text> </xsl:text>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template match="page" mode="pager_next">

   <xsl:param name="last_id"/>
   <xsl:choose>
        <xsl:when test="not(@id=$last_id)">

            <xsl:variable name="_href">
                 <xsl:for-each select="ancestor::folder">
                    <xsl:text>/</xsl:text>
                    <xsl:value-of select="@name"/>
                </xsl:for-each>
                <xsl:text>/</xsl:text>
                <xsl:variable name="next_label"
select="following-sibling::page/@label"/>
                <xsl:value-of select="translate($next_label, ' ', '_')"/>
                <xsl:value-of select="@file_ext"/>
            </xsl:variable>

             <a href="{$_href}">
                 next &#187;
            </a>

        </xsl:when>
        <xsl:otherwise>
            <xsl:text> </xsl:text>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>


Mime
View raw message