Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am trying to use the following code to make the root of sub-menu items appear highlighted when the sub items are selected.
This works on all pages, even those without sub-pages except the home page.
What am I missing?
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> <!ENTITY hidden "umbracoNaviHide = 1"> <!ENTITY node "*[@isDoc]">]><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="homeMenu" select="/macro/homeItem"/> <xsl:variable name="homePage" select="umbraco.library:GetXmlNodeById($homeMenu)"/><xsl:template match="/"> <xsl:if test="$homeMenu !=''"> <xsl:variable name="homePage" select="umbraco.library:GetXmlNodeById($homeMenu)"/> <ul> <xsl:apply-templates select="$homePage | $homePage/&node;"/> </ul> </xsl:if></xsl:template><xsl:template match="&node;"> <li> <xsl:if test="@id = $currentPage/ancestor-or-self::&node;/@id and @id != $homeMenu"> <xsl:attribute name="class"> current </xsl:attribute> </xsl:if> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="navigationName"/> </a> <xsl:variable name="nextLevel" select="current()"/> <xsl:if test="count($nextLevel/&node;) > 0 and position() != 1 and $nextLevel/&node; [umbracoNaviHide != 1] and @id != 1283"> <ul> <xsl:for-each select="$nextLevel/&node;"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="navigationName"/> </a> </li> </xsl:for-each> </ul> </xsl:if> </li></xsl:template> <xsl:template match="&node;[&hidden;]"/> </xsl:stylesheet>
Many thanks.
TT
Hi TT,
As far as I can see, you're actively excluding the homeMenu from getting the "current" class:
<xsl:if test="@id = $currentPage/ancestor-or-self::&node;/@id and @id != $homeMenu">
?
/Chriztian
Thank you for your reply Chriztian, I should have been clearer.
I am trying to exclude the homeMenu except when it is the page that has focus.
Regards
Michael
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
ancestor not selecting home item on menu
I am trying to use the following code to make the root of sub-menu items appear highlighted when the sub items are selected.
This works on all pages, even those without sub-pages except the home page.
What am I missing?
Many thanks.
TT
Hi TT,
As far as I can see, you're actively excluding the homeMenu from getting the "current" class:
?
/Chriztian
Thank you for your reply Chriztian, I should have been clearer.
I am trying to exclude the homeMenu except when it is the page that has focus.
Regards
Michael
is working on a reply...