Copied to clipboard

Flag this post as spam?

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


  • Bent Holz 100 posts 273 karma points
    Feb 24, 2016 @ 22:53
    Bent Holz
    0

    List sub categories with more than one main category

    I'm trying to create a product catalog that has main categories, sub categories and products...

    Sub categories can be under more than one main category and a product can be under more than one sub category.

    I have set up a doc type for my sub categories where I have added a data type (Ultimate Picker - CheckBoxList). This let's me choose what main categories a sub category belongs to when I create it.

    Now I would like XSLT to list the sub categories...

    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1'][string(hovedkategori) = '1137']">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>
    

    This will show all the sub categories that has the main category (ID 1137) selected... but only that ID. So a sub category that has more than that one main category selected will not show.

    How do I get it to show sub categories that among others have the specific main category ID?

    /cheers

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Feb 24, 2016 @ 23:01
    Chriztian Steinmeier
    100

    Hi Bent,

    Try using the Split() extension to get a <value> node for every category in the list - then it's easier to do the comparison:

    <xsl:variable name="sourceNode" select="umbraco.library:GetXmlNodeById($source)" />
    
    <xsl:for-each select="$sourceNode/*[@isDoc and not(umbracoNaviHide = 1)][umbraco.library:Split(hovedkategori, ',')/value = 1137]">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each> 
    

    Hope that helps,

    /Chriztian

  • Bent Holz 100 posts 273 karma points
    Feb 25, 2016 @ 15:35
    Bent Holz
    0

    That did the trick!

    Thank you so very much!

    /Bent

Please Sign in or register to post replies

Write your reply to:

Draft