title: Create Pagination in Umbraco Blog and News Page
body: <p>I am New to ASP.Net and Umbraco, Here i want to create a Pagination for Blog and News Listing Page. So here is my NewsLisitng.Xslt file. Please help me how can i create the pagination. Here i need a pagination like dispaly 1 to 10 links.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;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"
    xmlns:tagsLib="urn:tagsLib"
    xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"
    xmlns:BlogLibrary="urn:BlogLibrary"
    exclude-result-prefixes="msxml umbraco.library tagsLib Exslt.ExsltStrings BlogLibrary"&gt;
  
  
      &lt;xsl:output method="html" omit-xml-declaration="yes"/&gt;
  
      &lt;xsl:param name="currentPage"/&gt;
      &lt;xsl:variable name="numberOfPosts" select="2"/&gt;
  
      &lt;xsl:variable name="pageNumber"&gt;
          &lt;xsl:choose&gt;
              &lt;xsl:when test="umbraco.library:RequestQueryString('page') &amp;lt;= 0 or string(umbraco.library:RequestQueryString('page')) = '' or string(umbraco.library:RequestQueryString('page')) = 'NaN'"&gt;1&lt;/xsl:when&gt;
              &lt;xsl:otherwise&gt;
                  &lt;xsl:value-of select="umbraco.library:RequestQueryString('page')"/&gt;
              &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
      &lt;/xsl:variable&gt;
  
      &lt;xsl:variable name="filter"&gt;
          &lt;xsl:choose&gt;
              &lt;xsl:when test="string-length(umbraco.library:Request('filterby')) &amp;gt; 0"&gt;
                  &lt;xsl:value-of select="umbraco.library:Request('filterby')"/&gt;
              &lt;/xsl:when&gt;
              &lt;xsl:otherwise&gt;
                  &lt;xsl:value-of select="''"/&gt;
              &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
      &lt;/xsl:variable&gt;
  
      &lt;xsl:variable name="numberOfRecords"&gt;
          &lt;xsl:choose&gt;
              &lt;xsl:when test="$filter = ''"&gt;
                  &lt;xsl:value-of select="count($currentPage/ancestor-or-self::umbBlog//umbBlogPost)"/&gt;
              &lt;/xsl:when&gt;
              &lt;xsl:otherwise&gt;
                  &lt;xsl:value-of select="count($currentPage/ancestor-or-self::umbBlog//umbBlogPost [contains(Exslt.ExsltStrings:lowercase(./tags), Exslt.ExsltStrings:lowercase($filter))])"/&gt;
              &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
      &lt;/xsl:variable&gt;
  
      &lt;xsl:template match="/"&gt;
  
  
          &lt;xsl:if test="$filter != ''"&gt;
              &lt;h2 class="page-title"&gt;
                  Archive for tag:
                  &lt;span&gt;
                      &lt;xsl:value-of select="$filter"/&gt;
                  &lt;/span&gt;
              &lt;/h2&gt;
          &lt;/xsl:if&gt;
  
          &lt;xsl:if test="$currentPage [name() = 'umbDateFolder']"&gt;
              &lt;h2 class="page-title"&gt;
                  Monthly Archives: &lt;xsl:value-of select="umbraco.library:FormatDateTime(concat($currentPage/../@nodeName,'-',$currentPage/@nodeName,'-11T10:24:46'),'MMMM yyyy')"/&gt;
              &lt;/h2&gt;
          &lt;/xsl:if&gt;
  
          &lt;xsl:if test="$numberOfRecords &amp;gt; $numberOfPosts"&gt;
              &lt;div id="nav-above" class="navigation"&gt;
  
                  &lt;div class="nav-previous"&gt;
                      &lt;xsl:if test="(($pageNumber ) * $numberOfPosts) &amp;lt; ($numberOfRecords)"&gt;
                          &lt;span class="meta-nav"&gt;&amp;#171; &lt;/span&gt;
                          &lt;a href="?page={$pageNumber +1}"&gt;Older posts&lt;/a&gt;
                      &lt;/xsl:if&gt;
                  &lt;/div&gt;
  
                  &lt;div class="nav-next"&gt;
                      &lt;xsl:if test="$pageNumber &amp;gt; 1"&gt;
                          &lt;a href="?page={$pageNumber -1}"&gt;Newer posts&lt;/a&gt;
                          &lt;span class="meta-nav"&gt; &amp;#187;&lt;/span&gt;
                      &lt;/xsl:if&gt;
                  &lt;/div&gt;
  
              &lt;/div&gt;
          &lt;/xsl:if&gt;
  
          &lt;xsl:if test="$filter = ''"&gt;
  
  
              &lt;xsl:for-each select="$currentPage/ancestor-or-self::umbBlog//umbBlogPost"&gt;
                  &lt;xsl:sort select="./PostDate" order="descending" /&gt;
  
                  &lt;xsl:if test="position() &amp;gt; $numberOfPosts * (number($pageNumber)-1) and
          position() &amp;lt;= number($numberOfPosts * (number($pageNumber)-1) +
          $numberOfPosts )"&gt;
  
                      &lt;xsl:call-template name="showpost"&gt;
                          &lt;xsl:with-param name="post" select="."/&gt;
                      &lt;/xsl:call-template&gt;
  
                  &lt;/xsl:if&gt;
  
              &lt;/xsl:for-each&gt;
          &lt;/xsl:if&gt;
  
          &lt;xsl:if test="$filter != ''"&gt;
  
              &lt;xsl:for-each select="$currentPage/ancestor-or-self::umbBlog//umbBlogPost [contains(Exslt.ExsltStrings:lowercase(./tags), Exslt.ExsltStrings:lowercase($filter))]"&gt;
                  &lt;xsl:sort select="./PostDate" order="descending" /&gt;
                  &lt;xsl:if test="position() &amp;gt; $numberOfPosts * (number($pageNumber)-1) and
          position() &amp;lt;= number($numberOfPosts * (number($pageNumber)-1) +
          $numberOfPosts )"&gt;
                      &lt;xsl:call-template name="showpost"&gt;
                          &lt;xsl:with-param name="post" select="."/&gt;
                      &lt;/xsl:call-template&gt;
                  &lt;/xsl:if&gt;
              &lt;/xsl:for-each&gt;
          &lt;/xsl:if&gt;
  
      &lt;/xsl:template&gt;
  
      &lt;xsl:template name="showpost"&gt;
          &lt;xsl:param name="post"/&gt;
  
          &lt;div class="latestnews-wrap one-column-block hentry post publish author-{$post/@writername} tag-boat tag-lake {umbraco.library:FormatDateTime($post/@updateDate, 'yYYYY mMM')} y2008 m10 d17 h04"&gt;
              &lt;ul&gt;
                  &lt;li&gt;
                      &lt;div class="left-column"&gt;
                          &lt;div class="entry-date calendar"&gt;
                              &lt;abbr class="published" title="{umbraco.library:ShortDate($post/PostDate)}"&gt;
                                  &lt;span class="day"&gt;
                                      &lt;xsl:value-of select="umbraco.library:FormatDateTime($post/PostDate, 'MM/yy')"/&gt;
                                  &lt;/span&gt;
                              &lt;/abbr&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;!--.left-column--&gt;
                      &lt;div class="right-column"&gt;
                          &lt;h4 class="entry-title" id="post-{$post/@id}"&gt;
                              &lt;a href="{umbraco.library:NiceUrl($post/@id)}" title="Permalink to {$post/@nodeName}"&gt;
                                  &lt;xsl:value-of select="$post/@nodeName"/&gt;
                              &lt;/a&gt;
                          &lt;/h4&gt;
                          &lt;xsl:if test="$post/photo != ''"&gt;
                              &lt;xsl:variable name="media" select="umbraco.library:GetMedia($post/photo, 0)" /&gt;
                              &lt;xsl:if test="$media"&gt;
                                  &lt;div class="thumbNail"&gt;
                                      &lt;img src="{$media/umbracoFile}" alt="{$media/altText}"/&gt;
                                      &lt;xsl:if test="$post/photoCaption"&gt;
                                          &lt;span class="caption"&gt;
                                              &lt;xsl:value-of select="$post/photoCaption" /&gt;
                                          &lt;/span&gt;
                                      &lt;/xsl:if&gt;
                                  &lt;/div&gt;
                              &lt;/xsl:if&gt;
                          &lt;/xsl:if&gt;
  
                          &lt;div class="entry-content"&gt;
                              &lt;xsl:value-of select="$post/shortDescription" disable-output-escaping="yes"/&gt;
                          &lt;/div&gt;
  
                          &lt;a href="{umbraco.library:NiceUrl($post/@id)}" class="more-link news-more"&gt;Read More&lt;/a&gt;
                      &lt;/div&gt;
                      &lt;!--.right-column--&gt;
                  &lt;/li&gt;
              &lt;/ul&gt;
  
          &lt;/div&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>