Copied to clipboard

Flag this post as spam?

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


  • Elad Lachmi 112 posts 144 karma points
    Jul 03, 2011 @ 09:02
    Elad Lachmi
    0

    Link back to parent

    Hi,

    I'm trying to create a subnavigation menu with XSLT.

    I want, aside from showing all child nodes, I want a link back to the parent of the document.

    I would also like to omit this back link on the home page.

    <ul class="right-navi-list">
    <xsl:for-each select="$currentPage/ContentPage [@isDoc and string(umbracoNaviHide) != '1']">
    <li>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/>
    </a>
    </li>
    </xsl:for-each>
    <xsl:variable name="parent" select="$currentPage/ancestor-or-self::*" />
    <li>
    <a href="{umbraco.library:NiceUrl($parent/@id)}">
    Back
    </a>
    </li>
    </ul>

     

    This is what I have tried so far,

    but this just gives me a link to the current page.

  • Ernst Utvik 123 posts 235 karma points
    Jul 03, 2011 @ 09:52
    Ernst Utvik
    1

    Try this:

    <xsl:if test="$currentPage/@level != 1">
      <xsl:variablename="parent"select="$currentPage/parent::*"/>
       <li>
        <ahref="{umbraco.library:NiceUrl($parent/@id)}">
        Back
        </a>
       </li>

    </xsl:if>

  • Kim Andersen 1447 posts 2196 karma points MVP
    Jul 03, 2011 @ 12:40
    Kim Andersen
    1

    Hi Elad

    If you want to create a link to the parrent of the current page you can do like this:

    <a href="{umbraco.library:NiceUrl($currentPage/../@id)}">Back</a>

    The two dots ".." reffers to the parent node.

    /Kim A

  • 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