Menu (XSLT) question Options
Kim
Posted: Thursday, June 05, 2008 9:55:15 AM
Rank: Newbie

Joined: 5/21/2008
Posts: 5
Location: Denmark
Hi! Hope you can help me with this...

My topmenu
My 'frontpage' is selected all the time, and I only want it to be selected when the user is on that page.

Here is the code:

Code:
<ul>
<!-- Frontpage-->
<xsl:for-each select="$currentPage/ancestor-or-self::root/node">

<li>
<xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
<xsl:attribute name="id">current</xsl:attribute>
</xsl:if>

<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:attribute name="title"><xsl:value-of select="@nodeName"/></xsl:attribute>                
            <span>
                           <xsl:value-of select="@nodeName"/>
                        </span>
        </a>
</li>
</xsl:for-each>




<!-- other pages -->

<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <li><xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
<xsl:attribute name="id">current</xsl:attribute>
</xsl:if>
        <a href="{umbraco.library:NiceUrl(@id)}">
<xsl:attribute name="title"><xsl:value-of select="@nodeName"/></xsl:attribute>
                <!-- we're under the item - you can do your own styling here -->
                
            <span>
                           <xsl:value-of select="@nodeName"/>
                        </span>
        </a>
    </li>
</xsl:for-each>

</ul>


Is probably the if-argument that's wrong:

Code:
<xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">


I hope you can help, and thanks in advance!
Dirk
Posted: Thursday, June 05, 2008 10:09:41 AM

Rank: Fanatic

Joined: 9/27/2007
Posts: 411
Location: Belgium
Hi,

I've used about the same xslt on my site, except for this little detail

Code:
<xsl:if test="$currentPage/@id = $currentPage/ancestor-or-self::node [@level = 1]/@id">


instead of

Code:
<xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">


Of course, it would only work if your 'Frontpage' is top level node! At least, it works for me!

HTH.

Regards,
/Dirk



level 1 certified - umbraco blog at netaddicts.be
Kim
Posted: Thursday, June 05, 2008 10:13:29 AM
Rank: Newbie

Joined: 5/21/2008
Posts: 5
Location: Denmark
Thank you!

Applause
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.