Copied to clipboard

Flag this post as spam?

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


  • Ian Banks 24 posts 44 karma points
    Nov 07, 2010 @ 00:56
    Ian Banks
    0

    getting niceUrl error when trying to link to an ancestor

    Hello

    I am having a problem with niceUrl, I have defined two variables which stores the id and node name of an ancestor node. I do not get an error when saving, just an error when trying to render the macro content. Any help would be appreciated.

     

    <xsl:template name="listContributors">
        <xsl:variable name="blogPostNodeSet">
        <xsl:for-each select="$currentPage/descendant-or-self::node[@ nodeTypeAlias='BlogPost']">
                <xsl:sort order="descending" select="@createDate" />
                <xsl:if test="position() &lt; $numOfBlogs">
                    <xsl:copy-of  select="." />
                </xsl:if>
            </xsl:for-each>
        </xsl:variable>   
        <ul>
            <xsl:for-each select="msxsl:node-set($blogPostNodeSet)/node[not(@writerID = preceding-sibling::node/@writerID)]">
                <xsl:variable name="blogParent" select="ancestor::node[@nodeTypeAlias='Blog']/@id" />
                <xsl:variable name="blogParentName" select="ancestor::node[@nodeTypeAlias='Blog']/@nodeName" />   
                <li>
                    <a>
                        <xsl:attribute name="href">
                            <xsl:value-of select="umbraco.library:NiceUrl($blogParent)"/>   
                        </xsl:attribute>   

                        <xsl:value-of select="$blogParentName"/>
                    </a>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:template>

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Nov 07, 2010 @ 11:51
    Morten Bock
    0

    In think the reason is that the node set that you are saving in your variable no longer has ancestors. It's a completely new nodeset that only has the nodes you selected.

    So you probably need to use something like GetXmlNodeById(@id) to get the actual current node when populating the blogParent and blogParentName variables.

  • Ian Banks 24 posts 44 karma points
    Nov 07, 2010 @ 19:57
    Ian Banks
    0

    Thanks for the info I'll try that.

  • 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