Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 886 posts 2415 karma points
    Oct 27, 2010 @ 12:01
    Claushingebjerg
    0

    problem with ancestor-or-self::node

    i have a problem in a menu i built, where i want set an "active" class on the <a> tag of the page and its parent when the page is selected.

    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
            <xsl:attribute name="class">active</xsl:attribute>
    </
    xsl:if>  
       <xsl:value-of select="@nodeName"/>
    </
    a>


    does'nt apply "active" to any <a> , whereas the following sets the current page to "active" just fine

    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:if test="$currentPage/@id = current()/@id">
    <xsl:attribute name="class">active</xsl:attribute>
    </
    xsl:if>  
    <xsl:value-of select="@nodeName"/>
    </
    a>
  • Claushingebjerg 886 posts 2415 karma points
    Oct 27, 2010 @ 12:03
    Claushingebjerg
    0

    im running 4.5.2 by the way

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Oct 27, 2010 @ 12:08
    Lee Kelleher
    0

    Hi Claushingebjerg,

    Do you know if you are using the new XML schema? If so, try this:

    <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc]/@id = current()/@id">

    Cheers, Lee.

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Oct 27, 2010 @ 12:09
    Lee Kelleher
    1

    By-the-way, you don't need to use the "current()" part either.  Just "@id" is fine - the XSLT understands the context of the condition.

    <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc]/@id = @id">
  • Claushingebjerg 886 posts 2415 karma points
    Oct 27, 2010 @ 12:29
    Claushingebjerg
    0

    Grrrrrr damn schema....

    That did the trick, thanks :)

  • 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