Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Brian 77 posts 251 karma points
    Nov 24, 2014 @ 21:08
    Brian
    0

    Paging Issue with List

    Hi guys,

    Hope you can help me out with a paging issue...  

    I have created a list XSLT that includes page breaks, the page break button is being displayed but when it is clicked on it is the link is incorrect, instead of showing http://domainname.co.uk/theatrical-insights/?page=2 it is trying to resolve http://domainmame/theatrical-insights.aspx/?page=2

    Any idea how to remove the .aspx from the code below guys!?

    Cheers as ever for your help.

     

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "&#x00A0;">]>

    <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:param name="currentPage"/>

     

      <xsl:template match="featuredImage">

    <img src="{.}"  />

    </xsl:template>

      <xsl:template match="/">

      <xsl:variable name="excerptLength">

        <xsl:choose>

          <xsl:when test="string(/macro/excerptLength) != ''">

            <xsl:value-of select="/macro/excerptLength"/>

          </xsl:when>

          <xsl:otherwise>150</xsl:otherwise>

        </xsl:choose>

      </xsl:variable>

        <xsl:variable name="recordsPerPage" select="2"/>

        <xsl:variable name="pageNumber">

          <xsl:choose>

            <xsl:when test="umbraco.library:RequestQueryString('page') &lt;= 2 or string(umbraco.library:RequestQueryString('page')) = '' or string(umbraco.library:RequestQueryString('page')) = 'NaN'">1</xsl:when>

            <xsl:otherwise>

              <xsl:value-of select="umbraco.library:RequestQueryString('page')"/>

            </xsl:otherwise>

          </xsl:choose>

        </xsl:variable>

       <xsl:variable name="numberOfRecords" select="count($currentPage/parent::*/ReviewerSection/ReviewerBioPage/InsightArticle)"/>

        <ul>

    <xsl:for-each select="$currentPage/parent::*/ReviewerSection/ReviewerBioPage/InsightArticle [@isDoc and string(./umbracoNaviHide) != '1']">

              <xsl:sort select="@createDate" order="descending" /> 

     

            <xsl:if test="position() &gt; $recordsPerPage * number($pageNumber - 1) and position() &lt;= number($recordsPerPage * number($pageNumber - 1) + $recordsPerPage )">

     

    <li><a href="{umbraco.library:NiceUrl(@id)}">

    <figure><xsl:apply-templates select="ancestor-or-self::*[normalize-space(featuredImage)][1]/featuredImage" /></figure>

    <div class="homeinsighttext"><h4><xsl:value-of select="typeOfArticle" disable-output-escaping="yes"/></h4><h2><xsl:value-of select="@nodeName"/></h2>

    <p>

      <xsl:choose>

                    <xsl:when test="string($excerptLength) != '0'">

                      <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(articleContent), number($excerptLength), '...')" disable-output-escaping="yes"/>

                    </xsl:when>

                    <xsl:otherwise>

                      <xsl:value-of select="articleContent" disable-output-escaping="yes"/>

                    </xsl:otherwise>

                  </xsl:choose>

      </p>

    </div>

    </a>

    </li>

     

            </xsl:if>

     

          </xsl:for-each>

        </ul>

        <xsl:if test="$pageNumber &gt; 1">

          <a href="{umbraco.library:NiceUrl($currentPage/@id)}/?page={$pageNumber - 1}" class="navbuttonprev">Previous Page</a>

        </xsl:if>

        <xsl:call-template name="for.loop">

          <xsl:with-param name="i">100</xsl:with-param>

          <xsl:with-param name="page" select="$pageNumber"></xsl:with-param>

          <xsl:with-param name="count" select="ceiling(count($currentPage/parent::*/ReviewerSection/ReviewerBioPage/InsightArticle [@isDoc and string(./umbracoNaviHide) != '1']) div $recordsPerPage)"></xsl:with-param>

        </xsl:call-template>

        <xsl:if test="(($pageNumber) * $recordsPerPage) &lt; ($numberOfRecords)">

          <a href="{umbraco.library:NiceUrl($currentPage/@id)}/?page={$pageNumber + 1}" class="navbuttonnext">Next Page</a>

        </xsl:if>

      </xsl:template>

     

      <xsl:template name="for.loop">

        <xsl:param name="i"/>

        <xsl:param name="count"/>

        <xsl:param name="page"/>

        <xsl:if test="$i &lt;= $count">

          <xsl:if test="$page != $i">

            <a href="{umbraco.library:NiceUrl($currentPage/@id)}/?page={$i}" class="navbutton">

              <xsl:value-of select="$i" />

            </a>

          </xsl:if>

          <xsl:if test="$page = $i">

            <xsl:value-of select="$i" />

          </xsl:if>

        </xsl:if>

        <xsl:if test="$i &lt;= $count">

          <xsl:call-template name="for.loop">

            <xsl:with-param name="i">

              <xsl:value-of select="$i + 1"/>

            </xsl:with-param>

            <xsl:with-param name="count">

              <xsl:value-of select="$count"/>

            </xsl:with-param>

            <xsl:with-param name="page">

              <xsl:value-of select="$page"/>

            </xsl:with-param>

          </xsl:call-template>

        </xsl:if>

      </xsl:template>

    </xsl:stylesheet>

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Nov 24, 2014 @ 21:24
    Chriztian Steinmeier
    101

    Hi Brian,

    This must be Umbraco adding it from the NiceUrl() extension, which means you should check the setting in Web.config - enableDirectoryURLs (or similar) - but beware that this will of course change all URLs that are generated from the standard Navigation templates etc., so you may want to set up a RewriteRule as well to make sure any incoming request to a .aspx URL is forwarded to the extensionless URL instead.

    On a totally different note, you should have a look at my PaginationHelper for XSLT if you'd like to separate all the pagination code from the actual view code :-)

    /Chriztian

  • Brian 77 posts 251 karma points
    Dec 04, 2014 @ 15:54
    Brian
    0

    Hi Chriztian,

    Just trying to implement you solution by amending the webconfig file.  When I amend " <add key="umbracoUseDirectoryUrls" value="false" />" to  " <add key="umbracoUseDirectoryUrls" value="true" />" the website crashes with an internal error 500.  I'm clearly missing something but not sure what..

    any ideas?

    For info the server is hosted and not accessed by myself directly, in case that makes any difference.

Please Sign in or register to post replies

Write your reply to:

Draft