Copied to clipboard

Flag this post as spam?

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


  • Paul Griffiths 370 posts 1021 karma points
    Apr 16, 2014 @ 15:44
    Paul Griffiths
    0

    Help with nested xslt sort by

    Hi all

    I am trying to use a nested xslt sort by 2 parameters.

    I am looking to sort by venueName and also I have 5 premium venues that need to be displayed at the top also by venueName

    I have a property 'isPremiumVenue' and this is a true/false data type.

    So, in summary: sort by venueName and then sort where isPremiumVenue = 1 (so they display at the top of the results, all other non-premium venues to show underneath in venueName order)

    here is my code

    <xsl:variable name="premiumVenue" select="$sectionNode/isPremiumVenue = '1'" />
    
                <xsl:sort select="venueName" order="ascending"/>
    <xsl:sort select="$premiumVenue" order="ascending"/>        
    

    Could you help please?

    Thanks

    Paul

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Apr 16, 2014 @ 17:03
    Chriztian Steinmeier
    100

    Hi Paul,

    Use data-type="number" on the sort element and convert the boolean to a number to catch the off chance elements that don't have that property - so something like this:

    <xsl:sort select="venueName" order="ascending"/>
    <xsl:sort select="number(boolean(isPremiumVenue = 1))" data-type="number" order="descending"/>
    

    /Chriztian

  • Paul Griffiths 370 posts 1021 karma points
    Apr 17, 2014 @ 10:28
    Paul Griffiths
    0

    Hello Chriztian,

    Sorry for taking a while to respond, i have been away from the computer. However, Once again mate you code seemed to do the trick! :)

    For some reason it wouldn't work this way

    <xsl:sort select="venueName" order="ascending"/>
    <xsl:sort select="number(boolean(isPremiumVenue = 1))" data-type="number" order="descending"/>
    

    but this way works

    <xsl:sort select="number(boolean(isPremiumVenue = 1))" data-type="number" order="descending"/>
    <xsl:sort select="venueName" order="ascending"/>
    

    Either way I'm happy!!

    Thanks again

    Paul

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Apr 17, 2014 @ 10:34
    Chriztian Steinmeier
    0

    Ah - but of course :) Silly me. The other way round would sort venues without the isPremiumVenue property (or having it set to false) to the top first...

    /Chriztian

  • Paul Griffiths 370 posts 1021 karma points
    Apr 17, 2014 @ 10:55
    Paul Griffiths
    0

    Chriztian,

    Like always with your quick responses and great advice we managed to get there in the end, that is the main thing :).

    This forum and the fellow members are always a great help when your having a dull moment(which is frequent with me) ha.

    Paul

Please Sign in or register to post replies

Write your reply to:

Draft