Copied to clipboard

Flag this post as spam?

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


  • Craig O'Mahony 363 posts 917 karma points
    Sep 05, 2013 @ 16:17
    Craig O'Mahony
    0

    Create bespoke menu based on node id

    Hi Folks,

    I've got a standard menu structure on the go which builds a menu for top level items and any children that they may have. Everything is normal apart from two of the menu items (when clicked) should display a bespoke menu that relates only to them. So I want to see the normal menu apart from when the current page is id 1616 so.....

    <xsl:choose>
    <xsl:when test="$currentPage/ancestor-or-self::* [@isDoc]/@id = '1616'">
    <li class="selected"><a href="#">Middle East Office</a></li>
    <xsl:for-each select="$currentPage/* [@isDoc and @level = 3 and string(umbracoNaviHide) != '1']">
    <li>
    <xsl:if test="$currentPage/ancestor-or-self::* [@isDoc]/@id = current()/@id">
    <xsl:attribute name="class">
    <xsl:text>selected</xsl:text>
    </xsl:attribute>
    </xsl:if>
    <xsl:if test="umbraco.library:HasAccess(@id,@path)">
    <xsl:choose>
    <xsl:when test="$currentPage/ancestor-or-self::* [@isDoc]/@id = current()/@id">
    <a  href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName" />
    </a>
    </xsl:when>
    <xsl:otherwise>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName" />
    </a>  
    </xsl:otherwise>  
    </xsl:choose>   
    </xsl:if>
    </li>
    </xsl:for-each>
    </xsl:when>
    <xsl:otherwise>
    ////Build the normal menu////

    This works fine if the current id is 1616 but it doesn't work if the current document is a child of node id 1616 (which is what I want it to do!) - it doesn't do anything. Can anybody point me in the right direction please?

    Thanks,

    Craig

     

     

  • Kasper Dyrvig 246 posts 379 karma points
    Sep 16, 2013 @ 19:03
    Kasper Dyrvig
    100

    Hi Craig

    You can use $currentPage/@path to check is the current pages' path contains "1616". I have done it mostly in Razor, but it is possible to do in XSLT too.

  • Craig O'Mahony 363 posts 917 karma points
    Sep 17, 2013 @ 12:23
    Craig O'Mahony
    0

    Cheers Kasper,

    That's the way I went in the end :)

  • 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