Developer forum

Forum » Templates » selected menu item

selected menu item


Reply

Hello!

I'm new to DW so this question might be a dumb one. I'm playing around width xslt menus and cant seem to display a menu item as selected.Similar to 'Developer forum' beeing marked in blue on the top of this page. 

There was a previous posting about this where it was suggested to add a style like this: 

 

 

#top2Menu li a:active, li.MenuActive
{
/*what ever*/

}

 

This doesent seem to work for me.

 

My background is from PHP/javascript, and there something like this is easy to do, just check the query string, and display menu accordingly.

 

The page i'm working on can bee seen here:

http://eskanor.net.dynamicweb.no/

 

peace & love

 

-jan

 

 

 


Replies

 
Reply

Hi Jan

 

In your XML you have an attribute on each Page node called Active.

As default this has the value False.

 

But it will be Active on the page node that you clicked last.

 

This attribute you can use in an xsl:if test="@Active='True'" then apply an id or class and then you can style your active menuitem.

 

You might as well look at the attribute called @InPath which indicates the items you have clicked to reach a certain point in the navigation structure.

 

// Sebastian

 
Reply

Thank you for your quick reply!

 

 

I added the following code to my xslt:

 

<xsl:if test="@Active='True'">
         <xsl:attribute name="id">selected</xsl:attribute>
</xsl:if>
 

 

, just after the <li> tag.

 

and added this css:

 

#selected a { color:#FFFFFF; background-color:#433252; height:22px; }

 

this correctly changed the id attribute.

 

 

Thanks for the help :)

 

-jan

 

 

 
Grant Menzies
Reply

I have battled with trying to get this to work!

My menu code looks like this:

<a id="topMenuStyle">
                  <xsl:attribute name="class">
<xsl:if test="@InPath='True'">inpath</xsl:if>
<xsl:if test="position() = 1">firstitem</xsl:if>
<xsl:if test="position() = count(//Page)">lastitem</xsl:if>
<xsl:if test="@Active='True'">activeitem</xsl:if>
</xsl:attribute>
              <xsl:attribute name="tabindex">
              <xsl:value-of select="@Sort + 5"/>
            </xsl:attribute>
                        <xsl:attribute name="href">
              <xsl:value-of select="@FriendlyHref"/>
            </xsl:attribute>
            <xsl:value-of select="@MenuText"/>
            <span class="arrow3">
              <strong>&#160;</strong>
            </span>
          </a>

But I just cant seem to get the class "activeitem" to work.

Any ideas?

 

You must be logged in to post in the forum