Copied to clipboard

Flag this post as spam?

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


  • Palle Hansen 143 posts 396 karma points
    Apr 10, 2012 @ 20:52
    Palle Hansen
    0

    Sort on members custom properties

    Hi all,

    I'm having trouble with sorting on a custom member property.
    I'm using vers. 4.5.2.
    On a member group I can select a category. The category comes from a list in the content section.
    In the member section I use uComponents Multi-Node-Tree-Picker to choose the category.
    On my website I get a list of all members listed by category. That list sholud be listed in alphabetically order.
    But I can't make it work?

    First I make a variable to get all categories by the ID, and then get it to show the @nodeName. It works fine

    <xsl:variable name="Cats">
    <xsl:for-each select="$members/*">
    <xsl:variable name="Cat" select="umbraco.library:GetMember(@id)/node/customerkategorier"/>
    <xsl:value-of select="umbraco.library:GetXmlNodeById($Cat)/@nodeName"/>
    </xsl:for-each>
    </xsl:variable>

    But using the Cast variable in this code, it doesn't sort at all:

    <xsl:for-each select="$members/*">
    <xsl:sort select="$Cats" order="ascending"/>
    <xsl:variable name="Cat" select="umbraco.library:GetMember(@id)/node/customerkategorier"/>
    <xsl:value-of select="umbraco.library:GetXmlNodeById($Cat)/@nodeName"/>
    </xsl:for-each>

    Hope somebody can help.

    Best regards
    Palle

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Apr 11, 2012 @ 00:22
    Chriztian Steinmeier
    0

    Hi Palle,

    The reason it doesn't sort properly is that it's the same $Cats variable that's used in every iteration - for this to work, you need to select a property or computed value for every "member" you're iterating... trouble is, you're just iterating node ids (as far as I can tell from the code).

    I'm a little uncertain about which list you're trying to sort - is it the member list or the categories list?

    The big problem with this is really that the member nodes doesn't exist in the same XML document as the content nodes - if they did, it'd be quite easy to select one based on the other...

    To sort the members, what you really should do is to create a "set" containing all the member nodes and then sort that - but there doesn't seem to be a GetMembers() method (uComponents seem to have one, though).

    To sort the categories, you could just select them as any other set of content nodes and sort them - but again, you'd probably only want those that are used (i.e. selected by some member), right? Again, you'd need to perform the GetMember() function for every iteration which isn't very performant...

    So, which list is it?

    /Chriztian

     

  • Palle Hansen 143 posts 396 karma points
    Apr 11, 2012 @ 09:04
    Palle Hansen
    0

    Hi Chriztian,

    Thanks for your answer.
    I'm trying to sort the category list. And the category value is selected on a member.

     

    /Palle

Please Sign in or register to post replies

Write your reply to:

Draft