Search

bah, hey folks.

I have this xsl

<li>
        <a href="{$root}/{@handle}/" >
            <xsl:if test="@handle = $root-page">
                <xsl:attribute name="class">active</xsl:attribute>
            </xsl:if>
            <xsl:value-of select="name"/>
        </a>
    </li>

I want to add a .current class to the nav. I was thinking I could use addClass jquery. But I want to know how I would use and xsl if statement?

I just don't know what to test for, of the current page.. I mean if I do $current-page it adds the class still to all li's

That code already has one, the class is just active, instead of current.

If you want it on the li, you'll want to use this code:

<li>
    <xsl:if test="@handle = $root-page">
        <xsl:attribute name="class">current</xsl:attribute>
    </xsl:if>
    <a href="{$root}/{@handle}/"><xsl:value-of select="name"/></a>
</li>

The xsl:attribute name="class" is what you want to look at here.

hmm that did not work.

<a href="{$root}/{@handle}/">
                <!-- If the handle matches the root page, give our anchor a class of 'active' -->
                <xsl:if test="@handle = $root-page">
                    <xsl:attribute name="class">active</xsl:attribute>
                </xsl:if>
                <!-- Print the page's name -->
                <xsl:value-of select="name"/>
            </a>    </li>

you were right, it was already in the nav.xsl. oh well. Thanks!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details