Copied to clipboard

Flag this post as spam?

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


  • Martin 278 posts 661 karma points
    Oct 29, 2012 @ 09:57
    Martin
    0

    uComponents Multi-Node Tree Picker Recursive Macro

    Hi, 

    Im having some trouble with making my uComponents Multi-Node Tree Picker recursive.
    I have setup the MNTP for selecting widgets in the side column, but would like those widgets to be recursive. 

    I have seen a post about making a macro recursive, but i couldn't follow the logic.

    My XSLT is below.

    Any help would be grateful

     

    <xsl:param name="currentPage"/>
    <xsl:template match="/">
      <xsl:for-each select="$currentPage/sideColumnWidgets/MultiNodePicker/nodeId">
        <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(.)" />
        <!-- Handle the kind of node we got back -->
        <xsl:apply-templates select="$node" />
      </xsl:for-each>
    </xsl:template>    
            
       
    <!-- Template for SideBanner -->
    <xsl:template match="SideBanner">
      <xsl:variable name="media" select="umbraco.library:GetMedia(./image, 0)" />
      <xsl:if test="$media">
        <img class="scale-with-grid" src="{$media/umbracoFile}" alt="{$media/altText}"  />
      </xsl:if>
    </xsl:template>       
        
    <!-- Template for Side Widget -->
    <xsl:template match="SideWidget">
    <xsl:variable name="media" select="umbraco.library:GetMedia(./widgetImage, 0)" />
    <xsl:variable name="url" select="./url/url-picker"/>
    <a href="#">
    <xsl:attribute name="href">
    <xsl:choose>
    <xsl:when test="$url/@mode = 'URL'">
    <xsl:text>http://</xsl:text><xsl:value-of select="$url/url"/>
    </xsl:when>
    <xsl:when test="$url/@mode= 'Content'">
    <xsl:value-of select="umbraco.library:NiceUrl($url/node-id)"/>
    </xsl:when>

    </xsl:choose>
    </xsl:attribute>
    <xsl:if test="$media">
    <img class="scale-with-grid" src="{$media/umbracoFile}" alt="{$media/altText}"  />
    </xsl:if>
    </a>
    </xsl:template> 

    <!-- Template for Branches -->
    <xsl:template match="Branches">
     <!-- Root Node -->
        <xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::root" />  
    <!-- Input the documenttype you want here -->
    <xsl:variable name="documentTypeAlias" select="string('Branch')"/>
    <!-- The fun starts here -->
    <h4>Branch</h4>
    <ul>
    <xsl:for-each select="$rootNode/descendant-or-self::* [name() = $documentTypeAlias and string(umbracoNaviHide) != '1']">
    <li>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/>
    </a>
    </li>
    </xsl:for-each>
    </ul>
    </xsl:template>

     

     

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Nov 24, 2012 @ 03:08
    Lee Kelleher
    101

    Hi Martin,

    Not sure if you still need help with this issue?

    The XPath for getting a property value recursively is like this:

    $currentPage/ancestor-or-self::*[@isDoc and normalize-space(sideColumnWidgets/*/nodeId)][1]/sideColumnWidgets/*/nodeId

    The idea here is with the "ancestor-or-self" part the XPath is looking at itself and everything above it (starting with itself).  It then checks to see if it's a document (that's the @isDoc bit) and if it has a property (with a value) that matches "sideColumnWidgets/*/nodeId" (I swapped out the "MultiNodePicker" part with a wildcard, just because it makes the XPath too long).  From there it grabs the first node [1] and uses that property value.

    Hope that makes sense?

    Cheers, Lee.

  • 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