Copied to clipboard

Flag this post as spam?

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


  • aaronb 97 posts 116 karma points
    Jun 26, 2012 @ 19:18
    aaronb
    0

    sort select="position()" giving strange results

    I'm stumped on this one, I think I may be using position() wrong but I can't figure out why.

    I'm trying to display a list of documents in reverse order (the order they appear in the content tree, not the date they were created). My code loops through all the descendents and returns them in normal order if I remove the sort select line, but when I try to sort on position() with either descending or ascending they get returned in a very strange order that I can't see a pattern to. It seems to start at the 6th document in the 3rd quarter, then go all the way back to the top then start at the end to finish up. I can't spot any kind of pattern in this.

     

    My node structure looks like this:

    2012

     -first quarter
      -document one
      -document two

    - second quarter
      -document one
      -document two

    - third quarter
      -document one
      -document two

    - fourth quarter
      -document one
      -document two

    here's the important part of my code:

     <xsl:variable name="Source" select="$currentPage/currentYear" />
          <xsl:for-each select="umbraco.library:GetXmlNodeById($Source)/descendant-or-self::* [name() = 'PressRelease']">
            <xsl:sort select="position()" order="descending" />
            <p><xsl:value-of select="@nodeName" /> <xsl:value-of select="position()" /> </p>
          </xsl:for-each>

    Assuming I'm doing something wrong here, is there another way of doing this?

  • aaronb 97 posts 116 karma points
    Jun 26, 2012 @ 19:25
    aaronb
    1

    Solved - adding data-type="number" to the sort select statement got it all behaving itself.

Please Sign in or register to post replies

Write your reply to:

Draft