Sort order with @sortOrder Options
kenneth
Posted: Thursday, December 20, 2007 7:05:51 PM
Rank: Enthusiast

Joined: 10/2/2006
Posts: 25
Can anybody help Please?

When using @sortOrder in my menu the sort order is: 1, 10, 2, 3, 4, 5, 6, 7, 8, 9

How do I solve this so 10 will appear below 9?


Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml
umbraco.library">
   
<xsl:output method="xml" omit-xml-declaration="yes"/>   

<xsl:param name="currentPage"/> 
<xsl:param name="minLevel" select="3"/> 
<xsl:param name="maxLevel" select="4"/> 
 
<xsl:template match="/"> 

        <ul>
            <xsl:for-each select="$currentPage/ancestor-or-self::node [@level = $minLevel]/node [string(data [@alias='umbracoNaviHide']) != '1']"> 
              <xsl:sort select="@sortOrder" />     
                <xsl:call-template name="drawnode"> 
                 <xsl:with-param name="level" select="1"/>     
                </xsl:call-template> 
            </xsl:for-each> 
        </ul> 

</xsl:template> 
 
<xsl:template name="drawnode"> 
<xsl:param name="level"/> 



    <xsl:choose>
        <xsl:when test="count(./node[string(./data [@alias='umbracoNaviHide']) != '1']) >= 1 and @level > 2 and @level >= $maxLevel" >
            <li>
            <xsl:attribute name="class">level<xsl:value-of select="$level" /></xsl:attribute>
                
<a href="{umbraco.library:NiceUrl(@id)}" title="{@nodename}">
                      <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
                        <!-- we're under the item - you can do your own styling here -->
                        <xsl:attribute name="class">selected</xsl:attribute>
                     </xsl:if>

                    <xsl:value-of select="@nodeName"/>
        <xsl:value-of select="@sortOrder" />
                </a>
           </li>
        </xsl:when>
        <xsl:otherwise>
        <li>
        <xsl:attribute name="class">level<xsl:value-of select="$level" /></xsl:attribute>
         <a href="{umbraco.library:NiceUrl(@id)}" title="{@nodename}">
                    <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
                        <!-- we're under the item - you can do your own styling here -->
                        <xsl:attribute name="class">selected</xsl:attribute>
                    </xsl:if>
                    <xsl:value-of select="@nodeName"/>
               <xsl:value-of select="@sortOrder" />
     </a>
            </li>
    
        </xsl:otherwise>
    </xsl:choose>



    <xsl:if test="count(descendant-or-self::node [@id=$currentPage/@id]) > 0 and @level &lt;= $maxLevel"> 
        <xsl:for-each select="node [string(data [@alias='umbracoNaviHide']) != '1']"> 
          <xsl:sort select="@sortOrder" />
            <ul>
            <xsl:call-template name="drawnode"> 
                <xsl:with-param name="level" select="number($level)+1"/> 
            </xsl:call-template> 
            </ul>
        </xsl:for-each> 
    </xsl:if> 

</xsl:template>
</xsl:stylesheet>


Regards
Kenneth
drobar
Posted: Thursday, December 20, 2007 7:12:32 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,698
Location: KY, USA
In your xsl:sort, include <xsl:sort .... order="ascending" data-type="number"/>

cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.