Copied to clipboard

Flag this post as spam?

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


  • Phil Crowe 192 posts 256 karma points
    Nov 09, 2010 @ 15:06
    Phil Crowe
    0

    change order in loop

    i haven a foreach loop that lists some nodes and theyre properties. each item in the list is displayed in a div, all of these divs have a float left making it sit next to each other from left to right on the page. Just wondering is it possible to move an item to the front of this list(far left) if, for example it has a true/false datatype property that is set to true?

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Nov 09, 2010 @ 15:15
    Chriztian Steinmeier
    0

    Hi Phil,

    Sometimes it's just as easy to just process that one first, and then all the others, e.g.:

    <xsl:template match="/">
        <!-- Process the one you want first -->
        <xsl:apply-templates select="$currentPage/propertyNameOfFirstItem" />
    
        <!-- Process all others -->
        <xsl:apply-templates select="$currentPage/*[not(@isDoc)][not(self::propertyNameOfFirstItem)]">
            <xsl:sort order="ascending" />
        </xsl:apply-templates>
    </xsl:template>
    
    <!-- Template for a single property -->
    <xsl:template match="*[not(@isDoc)]">
        <div>
            <xsl:value-of select="name()" />: <xsl:value-of select="." />
        </div>
    </xsl:template>

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft