Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 karma points
    Aug 06, 2009 @ 16:08
    Claushingebjerg
    0

    Splitting odes from ultimate picker

    Hi

    Imcurrently building a small product catalogue.

    I have all my products in one folder. I render the individual products below "product Group" nodes by selecting them with the ultimate picker (alias=varegruppe ).

    The ultimate picker is defined on the "product" document type and is a checkbox list with the "product group nodes"

    I use the following xslt to list the products in the product groups they are connected to.

    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/node [string(data [@alias='umbracoNaviHide']) != '1']">
        <xsl:if test="data [@alias = 'varegruppe'] = $thispage">

                    <a href="{umbraco.library:NiceUrl(@id)}">

                   <xsl:value-of select="data [@alias = 'teaser']"/>
                    </a>
        </xsl:if>
    </xsl:for-each>

     

    So far so good, but this only works if the product has only one product group selected, example: 1109

    If multiple groups are selected, the output from the ultimate picker is like: 1109,1110,1111. And the it breaks

    So i would like to call in the cavalry on how to split the output on the above example, so that the products are shown on alle 3 productgroup pages, 1108,1110,1111.

    Hope this is clear enough. if not ill try to make it clearer.

    Thanks

     

     

  • dandrayne 1138 posts 2262 karma points
    Aug 06, 2009 @ 16:21
    dandrayne
    0

    This should do it, or help point you in the right direction

    <xsl:variable name="ultimatePicked" select="$currentPage/data[@alias='varegruppe']"/>
    <xsl:variable name="ultimatePickedItems" select="umbraco.library:Split($ultimatePicked, ',')" />
    <xsl:for-each select="$ultimatePickedItems/value">

    <xsl:variable name="ultimatePickedItem" select="." />
    <a href="{umbraco.library:NiceUrl(.)}">

    </xsl:for-each>

    Dan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Aug 06, 2009 @ 16:28
    Jan Skovgaard
    0

    As you can see from Dan's post you should use the Split function to achieve your task.

    It has been documented here http://our.umbraco.org/wiki/reference/umbracolibrary/split

    /Jan

  • Claushingebjerg 939 posts 2574 karma points
    Aug 07, 2009 @ 15:02
    Claushingebjerg
    0

    Ok, i get it in theory, but i still cant get it to work. I think maybe its a bit flipped on its head in my case.

    The green box are product groups. The red box are products. On each product i check which product groups the product should be shown in.

    How would i do this?

     

    Sorry for the newbie questions :)

  • Claushingebjerg 939 posts 2574 karma points
    Aug 07, 2009 @ 15:03
    Claushingebjerg
    0

    oh i tried to put in an image, that didnt work to well

    image can be found here http://www.proff-art.dk/splitexample.jpg

  • dandrayne 1138 posts 2262 karma points
    Aug 07, 2009 @ 15:33
    dandrayne
    100

    As it's a Friday I'm a little slow, but what you basically want to do is to is

    * on a product group page, iterate through the subnodes (products)
    * check that the 'varegruppe' property on the product node contains the id of the current page
    * if so, display

    the following xslt is completely untested, but the "contains" function can check the varegruppe string (1011, 1023, 101) to see if the current page id is present and if so display.  You should be able to do this from right within the foreach loop, without having to use an extra xsl:if

    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/node [string(data [@alias='umbracoNaviHide']) != '1' and contains(string(data [@alias='varegruppe']), string($thispage))]">

    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="data [@alias = 'teaser']"/>
    </a>

    </xsl:for-each>
  • Claushingebjerg 939 posts 2574 karma points
    Aug 07, 2009 @ 15:57
    Claushingebjerg
    0

    You just made my weekend, thanks. It seems to work

  • dandrayne 1138 posts 2262 karma points
    Aug 07, 2009 @ 16:13
    dandrayne
    0

    cool.  The only thing to remember is that with a check as simple as this you may eventually get false positives.

    E.g.  10110 "contains" 1011, as does 10111, 10112 etc etc.  If you see this being a problem eventually a few more checks may be required.

    Enjoy your weekend ;-)

Please Sign in or register to post replies

Write your reply to:

Draft