Copied to clipboard

Flag this post as spam?

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


  • gerald diva 11 posts 31 karma points
    Dec 01, 2010 @ 21:45
    gerald diva
    0

    Sorting Ultimate Picker Listbox data

    Hi,

    I have a Ultimate Picker Listbox called subtopics and I need to be able to sort the values ascending. Here is my code:

     

    <xsl:template name="column">
    <xsl:param name="start"/>
    <xsl:param name="end"/>
    <xsl:variable name="i" select="0"/>
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::root//node [@nodeTypeAlias='SpeakersByTopicListPage']/node">
    <xsl:sort select="@nodeName" order="ascending"/>
    <xsl:variable name="subtopicsList" select="data[@alias = 'Subtopics']"/>
    <xsl:if test="$i &gt;= $start and $i &lt;= $end and normalize-space($subtopicsList) != ''">
    <xsl:variable name="parentName">
    <xsl:choose>
    <xsl:when test="string(data[@alias = 'TopicName']) = ''">
    <xsl:if test="@template != 5187">
    <xsl:value-of select="@nodeName"/>
    </xsl:if>
    </xsl:when>
    <xsl:otherwise>
    <xsl:if test="@template != 5187">
    <xsl:value-of select="data[@alias = 'TopicName']"/>
    </xsl:if>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <xsl:if test="$parentName != ''">
    <li>
    <a class="parent" href="{umbraco.library:NiceUrl(@id)}/">
    <xsl:value-of select="$parentName"/>
    </a>
    </li>
    </xsl:if>
    <xsl:variable name="subtopics" select="umbraco.library:Split($subtopicsList,',')"/>
    <xsl:for-each select="$subtopics/value">
    <xsl:sort select="$subtopics/value" order="ascending"/>
    <xsl:variable name="subtopic" select="umbraco.library:GetXmlNodeById(.)"/>
    <xsl:variable name="name">
    <xsl:choose>
    <xsl:when test="string($subtopic/data[@alias = 'TopicName']) = ''">
    <xsl:value-of select="$subtopic/@nodeName"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$subtopic/data[@alias = 'TopicName']"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <xsl:if test="$subtopic/data[@alias = 'MoreSports'] = 0">
    <li>
    <a href="{umbraco.library:NiceUrl($subtopic/@id)}/">
    <xsl:value-of select="$name"/>
    </a>
    </li>
    </xsl:if>
    </xsl:for-each>
    </xsl:if>
    </xsl:for-each>
    </ul>
    </xsl:template>

    The code

    <xsl:sort select="$subtopics/value" order="ascending"/>

    is not working. Any help would be greatly appreciated thanks.

    Gerald

  • gerald diva 11 posts 31 karma points
    Dec 02, 2010 @ 01:39
    gerald diva
    0

    Figured it out. It was sorting by the Node ID's and thats why it was not working. Here is the correct code:

    <xsl:sort select="umbraco.library:GetXmlNodeById(.)/data[@alias = 'TopicName']" order="ascending" />
Please Sign in or register to post replies

Write your reply to:

Draft