Copied to clipboard

Flag this post as spam?

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


  • Sanjay Zalke 10 posts 30 karma points
    Jul 16, 2012 @ 15:30
    Sanjay Zalke
    0

    XSLT : How to read nested uComponent multinodepicker data

    Hi All,

    I have two nested uComponent Multi Node Picker Tree. I can read first level data and node details correctly, but as I traverse through second level nodes, XML data is not available. I can read the URL picker data correctly. Does anybody have solution to this?

     

    Site Structure:

    Home

    -- Page1

    -- Page2

    -- Page3

    -- Sections

    ----Section1

    ----Section2

    ----Section3

    ----Section4

     

    home page contains the collection of sections, which are selected by tree picker.

     

     

    Here is XML:

    <section id="1121" parentid="1118" level="3" writerid="0" creatorid="0" nodetype="1120" template="0" sortorder="1" createdate="2012-07-12T15:35:50" updatedate="2012-07-13T17:11:43" nodename="Our Solutions" urlname="our-solutions" writername="admin" creatorname="admin" path="-1,1068,1118,1121" isdoc="">
        <sectionlinks>
            <multinodepicker type="content">
                <nodeid>1098</nodeid>
                <nodeid>1097</nodeid>
                <nodeid>1099</nodeid>
                <nodeid>1100</nodeid>
            </multinodepicker>
        </sectionlinks>
        <morelink>
            <url-picker mode="Content">
                <new-window>False</new-window>
                <node-id>1087</node-id>
                <url>/solutions/</url>
                <link-title>More Services</link-title>
            </url-picker>
        </morelink>
        <title>Our Solutions</title>
        <bodytext>
        &lt;p&gt;Our Solutions details&lt;/p&gt;
        </bodytext>
        <summary>Our Solutions summary</summary>
        <breadcrumbtitle>our-solutions</breadcrumbtitle>
        <umbraconavihide>0</umbraconavihide>
        <sitename>
        <sitedescription>
        <homenodeid></homenodeid>
        </sitedescription>
        </sitename>
    </section>
    
    XSLT used to parse this:
    <xsl:template match="/">
      <!-- First we check that the Multi-node Tree Picker has any nodeId values -->
      <xsl:if test="$currentPage/sections/MultiNodePicker/nodeId">
        <ul>
          <!-- Loop through each of the nodeId values -->
          <xsl:for-each select="$currentPage/sections/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:call-template name="RenderSection">
              <xsl:with-param name="parent" select="."/>
            </xsl:call-template>      
          </xsl:for-each>
        </ul>
      </xsl:if>
    </xsl:template>

    <!-- Section Layout -->
    <xsl:template name="RenderSection">
      <xsl:param name="parent"/>
      <ul>
          <xsl:variable name="node" select="umbraco.library:GetXmlNodeById($parent)" />
          <li>
            <!-- Output the URL using umbraco.library's NiceUrl method -->
            <href="{umbraco.library:NiceUrl($parent)}">
              <xsl:value-of select="$node/@nodeName" />
            </a>
            <p><xsl:value-of select="$node/title" /></p>
            <p><xsl:value-of select="$node/bodyText" disable-output-escaping="yes" /></p>

            <!-- First we check that the Multi-node Tree Picker has any nodeId values -->
            <xsl:if test="$node/sectionlinks/MultiNodePicker/nodeId">
              <ul>
                <!-- Loop through each of the nodeId values -->
                <xsl:for-each select="$node/sectionlinks/MultiNodePicker/nodeId">
                  <xsl:variable name="childNode" select="umbraco.library:GetXmlNodeById(.)" />
                  <li
                    <href="{umbraco.library:NiceUrl($childNode)}">
                      <xsl:value-of select="$childNode/@nodeName" />
                    </a>
                  </li>
                </xsl:for-each>
              </ul>
            </xsl:if>

            <href="{umbraco.library:NiceUrl($node/moreLink/url-picker/node-id)}">
              <xsl:value-of select="$node/moreLink/url-picker/link-title" />
            </a>
          </li>
      </ul>
    </xsl:template>    

     

  • Sanjay Zalke 10 posts 30 karma points
    Aug 02, 2012 @ 14:43
    Sanjay Zalke
    0

    Anybody???

     

     Is it just me using a nested components?

     

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Aug 02, 2012 @ 15:24
    Chriztian Steinmeier
    0

    Hi Sanjay,

    The only thing I can spot here that seems to not do the right thing, is this one:

    <a href="{umbraco.library:NiceUrl($childNode)}">

    - at this point, $childNode points to a node, so to get the correct link, you should use $childNode/@id

    But that's not really the problem, I'm guessing?

    /Chriztian

  • 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