Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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:
-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?
Solved - adding data-type="number" to the sort select statement got it all behaving itself.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted