Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 3.02 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE xsl:stylesheet [
  3.         <!ENTITY nbsp "&#x00A0;">
  4. ]>
  5. <xsl:stylesheet
  6.         version="1.0"
  7.         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8.         xmlns:msxml="urn:schemas-microsoft-com:xslt"
  9.         xmlns:umbraco.library="urn:umbraco.library"
  10.         exclude-result-prefixes="msxml umbraco.library">
  11.         <xsl:output method="xml" omit-xml-declaration="yes" />
  12.  
  13.         <xsl:include href="_pagination.xslt"/>
  14.  
  15.         <xsl:param name="currentPage"/>
  16.         <xsl:variable name="page" select="umbraco.library:RequestQueryString('page')" />
  17.  
  18.         <xsl:template match="/">
  19.                 <xsl:variable name="matchedNodes" select="$currentPage/descendant::*[@isDoc]" />
  20.                 <xsl:variable name="nodeCount" select="count($matchedNodes)" />
  21.                 <xsl:if test="$nodeCount > 0">
  22.                         <xsl:variable name="page">
  23.                                 <xsl:choose>
  24.                                         <!-- first page -->
  25.                                         <xsl:when test="number(umbraco.library:RequestQueryString('page')) <= 1 or string(umbraco.library:RequestQueryString('page')) = '' or string(number(umbraco.library:RequestQueryString('page'))) = 'NaN'">
  26.                                                 <xsl:value-of select="number('1')" />
  27.                                         </xsl:when>
  28.                                         <!-- last page -->
  29.                                         <xsl:when test="number(umbraco.library:RequestQueryString('page')) > $nodeCount div $resultsPerPage">
  30.                                                 <xsl:value-of select="ceiling($nodeCount div $resultsPerPage)" />
  31.                                         </xsl:when>
  32.                                         <!-- the value specified in the url -->
  33.                                         <xsl:otherwise>
  34.                                                 <xsl:value-of select="number(umbraco.library:RequestQueryString('page'))"/>
  35.                                         </xsl:otherwise>
  36.                                 </xsl:choose>
  37.                         </xsl:variable>
  38.                         <xsl:variable name="startMatch" select="($page - 1) * $resultsPerPage + 1" />
  39.                         <xsl:variable name="endMatch">
  40.                                 <xsl:choose>
  41.                                         <!-- all the rest (on the last page) -->
  42.                                         <xsl:when test="($page * $resultsPerPage) > $nodeCount">
  43.                                                 <xsl:value-of select="$nodeCount" />
  44.                                         </xsl:when>
  45.                                         <!-- only the appropriate number for this page -->
  46.                                         <xsl:otherwise>
  47.                                                 <xsl:value-of select="$page * $resultsPerPage" />
  48.                                         </xsl:otherwise>
  49.                                 </xsl:choose>
  50.                         </xsl:variable>
  51.  
  52.                         <xsl:if test="$matchedNodes">
  53.                                 <xsl:apply-templates select="$matchedNodes">
  54.                                         <xsl:sort select="@createDate" order="descending" data-type="text" />
  55.                                         <xsl:with-param name="startMatch" select="$startMatch" />
  56.                                         <xsl:with-param name="endMatch" select="$endMatch" />
  57.                                 </xsl:apply-templates>
  58.                         </xsl:if>
  59.  
  60.                         <xsl:if test="$nodeCount > $resultsPerPage">
  61.                                 <xsl:call-template name="pagination">
  62.                                         <xsl:with-param name="page" select="$page" />
  63.                                         <xsl:with-param name="matchedNodes" select="$matchedNodes" />
  64.                                 </xsl:call-template>
  65.                         </xsl:if>
  66.  
  67.                 </xsl:if>
  68.                
  69.         </xsl:template>
  70.  
  71.         <xsl:template match="*[@isDoc]">
  72.                 <xsl:param name="startMatch" />
  73.                 <xsl:param name="endMatch" />
  74.                 <xsl:if test="position() >= $startMatch and position() <= $endMatch">
  75.                         <h3>
  76.                                 <a href="{umbraco.library:NiceUrl(@id)}">
  77.                                         <xsl:value-of select="@nodeName" />
  78.                                 </a>
  79.                         </h3>
  80.                         <p>
  81.                                 <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(bodyText), 175, '...')" disable-output-escaping="yes"/>
  82.                         </p>
  83.                         <hr />
  84.                 </xsl:if>
  85.         </xsl:template>
  86.  
  87. </xsl:stylesheet>