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
    Nov 02, 2012 @ 20:28
    Palle Hansen
    0

    Count selected items using ucomponents Multitreepicker

    Hi all,

    I  hope some one can help me.
    I have a list of nodes, where I can choose some items using ucomponents multitreepicker.

    I want to be able to count how many is selected with "Sport", "Movies" etc.
    I can choose more than one item on each nodes.

    What i have so so far is that I make a varbriable that loops throug all nodes, and that's returning a list of id's seperatede with comma
    <xsl:variable name="inter">
    <xsl:for-each select="$currentPage/ancestor::*//MedlemsContainer//Medlem/wwMinteresser">
    <xsl:value-of select="."/>  
    </xsl:for-each>
    </xsl:variable

    Now I what to count each selected items, but it returns a zero?

    <xsl:value-of select="count($currentPage/ancestor::*//MedlemsContainer//Medlem [$inter='1242'])"/>

    What do I do wrong?

    Palle

  • Palle Hansen 143 posts 396 karma points
    Nov 06, 2012 @ 17:00
    Palle Hansen
    0

    Does any one have an idea?

     

    Palle

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Nov 06, 2012 @ 21:25
    Chriztian Steinmeier
    0

    Hi Palle,

    If you're storing as XML (not CSV) it should be possible with a simple call to count() with some XPath jugglery... can you show a little bit about the structure in Contents - it's a little hard to grasp from the description... ? 

    /Chriztian

  • Palle Hansen 143 posts 396 karma points
    Nov 07, 2012 @ 08:07
    Palle Hansen
    0

    Hi Chriztian,
    Thanks for your reply.
    I'm storing as XML

    My structure in Content is like this:
    I have a Folder called InteresseContainer. Underneath I have my nodes to selected in the multi treepicker. (like Sport, Movies etc..)

    To get to my node with the the multitreepicker the structure is like this
    :
    - MedlemsContainer
      -
    AlphabetFolder
        -  Medlem

    The two folders InteresseContainer and MedlemsContainer are both at level 1

    Hope that can help.

    Palle

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Nov 07, 2012 @ 08:23
    Chriztian Steinmeier
    0

    Alright,

    This should get you started then:

    <xsl:variable name="absRoot" select="$currentPage/ancestor::root" />
    <xsl:variable name="interesser" select="$absRoot/InteresseContainer//Interesse" />
    <xsl:variable name="medlemmer" select="$absRoot/MedlemsContainer//Medlem" />
    
    <xsl:template match="/">
        <xsl:for-each select="$interesser">
            <p>
                <xsl:value-of select="@nodeName" />
                (<xsl:value-of select="count($medlemmer[wwMinteresser//nodeId = current()/@id])" />)
            </p>
        </xsl:for-each>   
    </xsl:template>
    
    Check the doctype aliases and the wwMinteresser property - I don't know if they're correct, but should be easy to change... 

    /Chriztian

  • Palle Hansen 143 posts 396 karma points
    Nov 07, 2012 @ 16:13
    Palle Hansen
    0

    Hi again Chriztian,

    I've checked all the aliases and property and they are allright, but it doesn't show anything, not even the @nodeName.
    There is no errors on the page and no errors when I save the XSLT?

    What could be wrong yuo think?

    Palle

  • Palle Hansen 143 posts 396 karma points
    Nov 07, 2012 @ 16:28
    Palle Hansen
    0

    Ahh sorry my fault....
    I've looked at the wrong datatype. I'm storing as CSV, so what to do when I'm using that?

    Could you try to help in that way?

     

    Palle

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Nov 07, 2012 @ 16:30
    Chriztian Steinmeier
    0

    Hi Palle,

    Then the two containers may not be at level 1 afterall - are they below "Content" or below a "Home" (or similar) node?

    Try adding an extra slash to those, just to check that they are in fact in the XML:

    <xsl:variable name="interesser" select="$absRoot//InteresseContainer//Interesse" />
    <xsl:variable name="medlemmer" select="$absRoot//MedlemsContainer//Medlem" />

    - this is very inefficient, but should work if they are somewhere in the tree... Does that help?

    /Chriztian

  • Palle Hansen 143 posts 396 karma points
    Nov 07, 2012 @ 17:44
    Palle Hansen
    0

    Hi Chriztian,

    Yes, that help.
    But it seems like the count is wrong. I get (0) for each @nodeName and that's not completely right. There is selected some.
    Mabye it's becourse of my reading wrong about XLM and CSV like my former post?

     

    Palle

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Nov 07, 2012 @ 23:01
    Chriztian Steinmeier
    1

    Hi Palle,

    Yeah I wrote that reply while you wrote the other one in between.

    So, yes - you need to store as XML for that to work, however, it should be possible to create a workaround for using CSV.

    It should be something like this:

    <xsl:value-of select="count($medlemmer[umbraco.library:Split(wwMinteresser, ',')/value = current()/@id])" />

    /Chriztian

  • Palle Hansen 143 posts 396 karma points
    Nov 08, 2012 @ 10:11
    Palle Hansen
    0

    Hi Chriztian,

    Thanks. That did the trick.
    And sorry for the mix up with XML and CSV

    Thanks again.

    Palle

  • 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