- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE xsl:stylesheet [
- <!ENTITY nbsp " ">
- ]>
- <xsl:stylesheet
- version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:msxml="urn:schemas-microsoft-com:xslt"
- xmlns:umbraco.library="urn:umbraco.library"
- exclude-result-prefixes="msxml umbraco.library">
- <xsl:output method="xml" omit-xml-declaration="yes" />
- <xsl:include href="_pagination.xslt"/>
- <xsl:param name="currentPage"/>
- <xsl:variable name="page" select="umbraco.library:RequestQueryString('page')" />
- <xsl:template match="/">
- <xsl:variable name="matchedNodes" select="$currentPage/descendant::*[@isDoc]" />
- <xsl:variable name="nodeCount" select="count($matchedNodes)" />
- <xsl:if test="$nodeCount > 0">
- <xsl:variable name="page">
- <xsl:choose>
- <!-- first page -->
- <xsl:when test="number(umbraco.library:RequestQueryString('page')) <= 1 or string(umbraco.library:RequestQueryString('page')) = '' or string(number(umbraco.library:RequestQueryString('page'))) = 'NaN'">
- <xsl:value-of select="number('1')" />
- </xsl:when>
- <!-- last page -->
- <xsl:when test="number(umbraco.library:RequestQueryString('page')) > $nodeCount div $resultsPerPage">
- <xsl:value-of select="ceiling($nodeCount div $resultsPerPage)" />
- </xsl:when>
- <!-- the value specified in the url -->
- <xsl:otherwise>
- <xsl:value-of select="number(umbraco.library:RequestQueryString('page'))"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="startMatch" select="($page - 1) * $resultsPerPage + 1" />
- <xsl:variable name="endMatch">
- <xsl:choose>
- <!-- all the rest (on the last page) -->
- <xsl:when test="($page * $resultsPerPage) > $nodeCount">
- <xsl:value-of select="$nodeCount" />
- </xsl:when>
- <!-- only the appropriate number for this page -->
- <xsl:otherwise>
- <xsl:value-of select="$page * $resultsPerPage" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="$matchedNodes">
- <xsl:apply-templates select="$matchedNodes">
- <xsl:sort select="@createDate" order="descending" data-type="text" />
- <xsl:with-param name="startMatch" select="$startMatch" />
- <xsl:with-param name="endMatch" select="$endMatch" />
- </xsl:apply-templates>
- </xsl:if>
- <xsl:if test="$nodeCount > $resultsPerPage">
- <xsl:call-template name="pagination">
- <xsl:with-param name="page" select="$page" />
- <xsl:with-param name="matchedNodes" select="$matchedNodes" />
- </xsl:call-template>
- </xsl:if>
- </xsl:if>
- </xsl:template>
- <xsl:template match="*[@isDoc]">
- <xsl:param name="startMatch" />
- <xsl:param name="endMatch" />
- <xsl:if test="position() >= $startMatch and position() <= $endMatch">
- <h3>
- <a href="{umbraco.library:NiceUrl(@id)}">
- <xsl:value-of select="@nodeName" />
- </a>
- </h3>
- <p>
- <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(bodyText), 175, '...')" disable-output-escaping="yes"/>
- </p>
- <hr />
- </xsl:if>
- </xsl:template>
- </xsl:stylesheet>