Copied to clipboard

Flag this post as spam?

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


  • Roger 195 posts 474 karma points
    Mar 05, 2015 @ 18:27
    Roger
    0

    XSLT Sort Issue

    Hi all, this is probably really simple but...

    I have an XSLT sort for records to show descending

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

    The records in the database have now reached over 1000 and the sort has stopped at 999 records.

    Here's the full XSLT:

    <xsl:variable name="comments" select="UCommentLibrary:GetCommentsForNode($currentPage/@id)//comment"/>
    
      <h3>
        Showing 100 of <xsl:value-of select="count($comments)"/> comment<xsl:if test="count($comments) &gt; 1">s</xsl:if>  in our  <xsl:value-of select="$currentPage/@nodeName"/>
      </h3>
    
      <ol class="commentlist">
        <xsl:for-each select="$comments">
            <xsl:sort select="@id" order="descending"/>
        <xsl:if test="position() &lt;= 100">
          <li class="comment" id="comment-{@id}">
            <div class="comment-author">
    
              <span class="fn n">
    
                        <xsl:value-of select="./name"/>
    
    
              </span>
            </div>
            <div class="comment-meta">
              Posted <xsl:value-of select="umbraco.library:LongDate(@created,'true',' at ')"/>
            </div>
            <p>
              <xsl:value-of select="umbraco.library:ReplaceLineBreaks(./message)" disable-output-escaping="yes"/>
            </p>
    
          </li>
            </xsl:if>
        </xsl:for-each>
      </ol>
    

    Can anyone help please?

    many thanks!

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Mar 05, 2015 @ 18:42
    Chriztian Steinmeier
    100

    Hi Roger,

    Could very well just be that you need to tell the processor to sort numerical (the default is "text" - so you'll find item #1000 at the very end when sorting using descending) - try this:

    <xsl:sort select="@id" data-type="number" order="descending" />
    

    /Chriztian

  • Roger 195 posts 474 karma points
    Mar 06, 2015 @ 16:53
    Roger
    0

    Thanks Chriztian, worked perfectly :)

Please Sign in or register to post replies

Write your reply to:

Draft