Developer forum

Forum » Templates » Unique menu id/class

Unique menu id/class

Sofia Soje
Reply

Is it possible to get an unique id/class code for the xslt menu navigation? As in: one link could have another css style.

Etc.

<xsl:attribute name="class">
    <xsl:text>menu-link menu-id-<!--@Menu.ID--></xsl:text>
    <xsl:if test="$inPath='True'">
        <xsl:text> active-menu</xsl:text>
    </xsl:if>
</xsl:attribute>
 

.menu-id-10{
     background:red;
}


Replies

 
Nicolai Pedersen
Reply

Hi Sofia

You can use the ID attribute of the page node - and do something like this:

<xsl:attribute name="class">
    <xsl:text>menu-link menu-id-</xsl:text><xsl:value-of select="@ID" disable-output-escaping="yes"/>
    <xsl:if test="$inPath='True'">
        <xsl:text> active-menu</xsl:text>
    </xsl:if>
</xsl:attribute>

BR Nicolai

 
Sofia Soje
Reply

Fabulous! Works like a charm!

Thank you, Nicolai!

 

You must be logged in to post in the forum