Copied to clipboard

Flag this post as spam?

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


  • Calvin Frei 106 posts 314 karma points
    Jun 04, 2010 @ 23:13
    Calvin Frei
    0

    XSLT Sort With DropDownList (<select>)?

    Hello

    I sort my XSLT with

    <xsl:sort select="./data [@alias = 'prize']" data-type="text" order="ascending" />

    but i will that the user can choose the sort with

    <select>
         <option>...</option>
    </select>

    or something like that with these options

    <xsl:sort select="./data [@alias = 'prize']" data-type="text" order="descending" />
    <xsl:sort select="@nodeName" data-type="text" order="ascending" />
    <xsl:sort select="umbraco.library:FormatDateTime(./data [@alias = 'date'], 'dd.MM.yyyy')" order="ascending" />

    is that possible?

    Best Regards

  • Calvin Frei 106 posts 314 karma points
    Jun 09, 2010 @ 22:46
    Calvin Frei
    0

    I have a solution, but it will not work perfectly

    I get the sort by url parameters, for example:

    http://yourdomain.com/categories/phones/xyz.aspx?sortby=[@alias = 'prize']&datatype=number&sortorder=ascending
    http://yourdomain.com/categories/phones/xyz.aspx?sortby=@nodeName&datatype=number&sortorder=ascending

    In the XSLT:

    <xsl:param name="SortBy">
     <xsl:choose>
      <xsl:when test="umbraco.library:RequestQueryString('sortby') != ''">
       <xsl:value-of select="umbraco.library:RequestQueryString('sortby')" />
      </xsl:when>
      <xsl:otherwise>
       <xsl:text>@sortOrder</xsl:text>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:param>
    <xsl:variable name="DataType">
     <xsl:choose>
      <xsl:when test="umbraco.library:RequestQueryString('datatype') != ''">
       <xsl:value-of select="umbraco.library:RequestQueryString('datatype')" />
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="'text'" />
      </xsl:otherwise>
     </xsl:choose>
    </xsl:variable>
    ...

    I will try to get [@alias = 'prize'] for <xsl:sort select="[@alias = 'prize']" ... /> with

    <xsl:sort select="$SortBy" order="{$SortOrder}" data-type="{$DataType}"/>

    but this doesn't work! Only

        <xsl:sort select="data[@alias = $SortBy]" order="{$SortOrder}" data-type="{$DataType}"/>

    works for me, but here is the $SortBy prize or date but I need @nodeName, prize and date!

  • 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