Having some issues with assigning a 'current' class to a macro. Basically I've created a custom menu from four content pickers which is pointing to specific sections of the site - however I cannot figure out how to create an 'active state' to the menu points.
So now I need to figure out if the current page that I am on is the same as one the four individual links, and if so - attach the 'current' class to each of them.
Does it make sense? I'm not much of a guru yet to this but at least I'm learning! :)
if id is same as contentpicker value
Having some issues with assigning a 'current' class to a macro. Basically I've created a custom menu from four content pickers which is pointing to specific sections of the site - however I cannot figure out how to create an 'active state' to the menu points.
So now I need to figure out if the current page that I am on is the same as one the four individual links, and if so - attach the 'current' class to each of them.
Does it make sense? I'm not much of a guru yet to this but at least I'm learning! :)
Hi Daniel,
Try this:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets "> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="currentPage"/> <xsl:variable name="level" select="2"/> <xsl:template match="/"> <!-- start writing XSLT --> <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]"> <ul id="priorityMenu"> <li> <a href="{umbraco.library:NiceUrl(firstLink)}" class="speech"> <xsl:if test="$currentPage/@id = firstLink"> <xsl:attribute name="class">selected speech</xsl:attribute> </xsl:if> <xsl:value-of select="firstLinkName"/> </a> </li> <li> <a href="{umbraco.library:NiceUrl(secondLink)}" class="speech"> <xsl:if test="$currentPage/@id = secondLink"> <xsl:attribute name="class">selected speech</xsl:attribute> </xsl:if> <xsl:value-of select="secondLinkName"/> </a> </li> <li> <a href="{umbraco.library:NiceUrl(thirdLink)}" class="speech"> <xsl:if test="$currentPage/@id = thirdLink"> <xsl:attribute name="class">selected speech</xsl:attribute> </xsl:if> <xsl:value-of select="thirdLinkName"/> </a> </li> <li> <a href="{umbraco.library:NiceUrl(fourthLink)}" class="speech"> <xsl:if test="$currentPage/@id = fourthLink"> <xsl:attribute name="class">selected speech</xsl:attribute> </xsl:if> <xsl:value-of select="fourthLinkName"/> </a> </li> </ul> </xsl:for-each> </xsl:template> </xsl:stylesheet>Thank you! Much appreciated, that did the trick!
I figured it wasn't that difficult and I'm sure I could've figured it out myself - must've hit a wall there. :D
You're welcome! And welcome to the Umbraco community!
is working on a reply...
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.