Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1287 posts 2744 karma points
    Sep 14, 2011 @ 23:25
    Amir Khan
    0

    Separate properties by parent node

    Hi,

    I have the below XSLT which is grabbing the values selected by a multi-node-tree-picker on the children of the homepage of my site. Is there a way to separate the children in the XSLT? I'd like to put each of them into a separate list instead of having one list containing all of the values of the pickers. I'm not sure how to say "for each child do this, then for each of their children do this"

    So right now I get:

    Homepage

    • item 1 from child 1
    • item 2 from child 1
    • item 1 from child 2
    • item 2 from child 2

    What I'd like to achieve is

    Div

    • Item 1 from child 1
    • item 2 from child 1

    Div

    • Item 1 from child 2
    • item 2 from child 2
    <xsl:if test="$currentPage/topStories/MultiNodePicker/nodeId">

        <ul>

          <!-- Loop through each of the nodeId values -->
          <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']/topStories/MultiNodePicker/nodeId">

            <!-- Since we only have the nodeId value, we need to get the actual content node using umbraco.library's GetXmlNodeById method -->
            <!-- If you prefer to use pure XPath, then used this: "$currentPage/ancestor-or-self::*[@isDoc and @level = 1]/descendant-or-self::*[@isDoc and @id = current()]" -->
            <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(.)" />
            <li>

              <!-- Output the URL using umbraco.library's NiceUrl method -->
              <a href="{umbraco.library:NiceUrl(.)}">

                <xsl:value-of select="$node/@nodeName" />

              </a>

            </li>
          </xsl:for-each>

        </ul>

      </xsl:if>

    Thanks for your help!

    Amir

Please Sign in or register to post replies

Write your reply to:

Draft