Copied to clipboard

Flag this post as spam?

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


  • SaphuA 124 posts 87 karma points
    Oct 14, 2009 @ 12:54
    SaphuA
    0

    Sorting

    Hello,

    I have the following xslt that spits out some xml:

    <xsl:for-each select="$parent/node [string(./data [@alias='umbracoNaviHide']) != '1']">
    <xsl:sort select="@sortOrder" />
    ...
    </xsl:for-each>

    However, the created items are not in the same order as in the Umbraco Content view.
    Am I doing something wrong?

    Thanks!

  • Roger Hughes 55 posts 88 karma points
    Oct 14, 2009 @ 13:17
    Roger Hughes
    0

    Hi, try something like:

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

    <xsl:sort select="@sortOrder" order="ascending"/>

     

    Rog ;-)

  • SaphuA 124 posts 87 karma points
    Oct 14, 2009 @ 13:34
    SaphuA
    0

    Thanks for your reply, but that didn't work. I think "ascending" is the default value anyway.

    I'm starting to think that this is a bug in umbraco. Because when I use descending, I get the same scrambled order, but reversed. I've tried republishing every node, but without succes.

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Oct 14, 2009 @ 13:37
    Douglas Robar
    0

    What version of umbraco are you using? There was a bug with really long node names in one of the v3 versions.

    cheers,
    doug.

  • SaphuA 124 posts 87 karma points
    Oct 14, 2009 @ 13:44
    SaphuA
    0

    v4.0.2.1

    I think I've figured it out! Here's the result of the sorting:

    0 1 10 11 12 2 3 4 5 6 7 8 9

    It appears it's sorting it as a string and not as an int. I suck at xslt, so I don't know how I can make it treat sortOrder as an int, will get back when I find it.

  • SaphuA 124 posts 87 karma points
    Oct 14, 2009 @ 13:47
    SaphuA
    0

    Aaaand found it.

    <xsl:sort select="@sortOrder" data-type="number" />

    Thanks for the help everyone!

  • Roger Hughes 55 posts 88 karma points
    Oct 14, 2009 @ 15:00
    Roger Hughes
    0

    excellent, i'll make a note of that one :-)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies