Copied to clipboard

Flag this post as spam?

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


  • Niels 63 posts 119 karma points
    Feb 16, 2012 @ 16:33
    Niels
    0

    Error parsing with Multi-node tree picker

    I use the Multi-node tree picker on a project for a navigation, but when I delete a node/page(that is selected in te mntp), I get a parsing error. My xslt looks like this:

    <xsl:variable name="selection" select="umbraco.library:GetXmlNodeById($frontpage/@id)" />
        <xsl:for-each select="$selection/navigatiePrimair/MultiNodePicker/nodeId">
          <xsl:if test="$selection/navigatiePrimair/MultiNodePicker/nodeId != ''">
            <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(.)" />
            <li>
              <xsl:if test="descendant-or-self::*[$node//@id = $currentPage/@id]">
                <xsl:attribute name="class">current</xsl:attribute>
              </xsl:if>
              <a href="{umbraco.library:NiceUrl($node/@id)}">
                <xsl:value-of select="$node/@nodeName"/>
              </a>
            </li>
          </xsl:if>
        </xsl:for-each>

    Help is needed on this one, thank you.

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Feb 16, 2012 @ 23:21
    Lee Kelleher
    0

    Hi Niels,

    When using the 'GetXmlNodeById' function, if the content node doesn't exist, then an <error> node is returned - which is causing you the headache.

    The quick fix for this is to wrap an <xsl:if> condition around the list-item, like so:

    <xsl:variable name="selection" select="umbraco.library:GetXmlNodeById($frontpage/@id)" />
    <xsl:for-each select="$selection/navigatiePrimair/MultiNodePicker/nodeId">
        <xsl:if test="$selection/navigatiePrimair/MultiNodePicker/nodeId != ''">
            <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(.)" />
            <xsl:if test="$node[@isDoc]">
                <li>
                    <xsl:if test="descendant-or-self::*[$node/@id = $currentPage/@id]">
                        <xsl:attribute name="class">current</xsl:attribute>
                    </xsl:if>
                    <a href="{umbraco.library:NiceUrl($node/@id)}">
                        <xsl:value-of select="$node/@nodeName"/>
                    </a>
                </li>
            </xsl:if>
        </xsl:if>
    </xsl:for-each>

    This checks that the $node has an attribute call "isDoc" (which all content nodes have).  Otherwise it's an <error> tag and the content node doesn't exist.

    Hope this helps?

    Cheers, Lee.

  • Niels 63 posts 119 karma points
    Feb 17, 2012 @ 09:16
    Niels
    0

    Yes! That did the trick. Thank you for the solution and the explanation. 

    Thanks again, Niels

Please Sign in or register to post replies

Write your reply to:

Draft