I was wondering if there is any code for checking if the current node in the navigation is active? By active i mean if the current node if the page I'm currently watching..
I have tried search for any "active" questions, but couldn't find anything :)
@montana: Just search for it - it's called "flexible navigation" - but agreed; there ought to be some URL redirection going on for the old URLs to packeages/projects
<xsl:template name="drawNodes"> <xsl:param name="parent"/> <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)"> <xsl:for-each select="$parent/* [@isDoc and @level <= $maxLevelForSitemap and string(umbracoNaviHide)!='1']">
<li onmouseover="$(this).addClass('over');" onmouseout="$(this).removeClass('over');" > <!-- duplicate ^ "over' class here to "open" class from below and you have a fully expandable/collapsable with active state hierarchical menu-->
Active navigation node - Any code for that?
Hello all :-)
I was wondering if there is any code for checking if the current node in the navigation is active? By active i mean if the current node if the page I'm currently watching..
I have tried search for any "active" questions, but couldn't find anything :)
Hi,
In an umbraco macro the $currentPage variable contains the node that the user is currently on.
If you want to learn more about navigation or need a simple leg up to get your nav started take a look at my http://our.umbraco.org/projects/cogworks---flexible-navigation">navigation package
Tim
@Tim
"...nav started take a look at my navigation package"
^ broken link
Hi Daniel,
You can ask that question like this, e.g., if you're inside a for-each on document nodes:
<!-- Inside xsl:template or xsl:for-each --> <xsl:if test="@id = $currentPage/@id"> <!-- stuff --> </xsl:if>
/Chriztian
Gee - old thread :-)
@montana: Just search for it - it's called "flexible navigation" - but agreed; there ought to be some URL redirection going on for the old URLs to packeages/projects
/Chriztian
I just started with umbraco and this was a hot topic - was just hitting all the threads trying to dig this up. Ended up writing 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" xmlns:tagsLib="urn:tagsLib"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="level" select="1"/>
<xsl:variable name="source" select="umbraco.library:GetXmlNodeByXPath('/root') [string(umbracoNaviHide)!='1']" />
<!--
update this variable on how deep your site map should be
-->
<xsl:variable name="maxLevelForSitemap" select="10"/>
<xsl:template match="/">
<ul class="nav_list">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="$source"/>
</xsl:call-template>
</ul>
</xsl:template>
<xsl:template name="drawNodes">
<xsl:param name="parent"/>
<xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
<xsl:for-each select="$parent/* [@isDoc and @level <= $maxLevelForSitemap and string(umbracoNaviHide)!='1']">
<li onmouseover="$(this).addClass('over');" onmouseout="$(this).removeClass('over');" >
<!-- duplicate ^ "over' class here to "open" class from below and you have a fully expandable/collapsable with active state hierarchical menu-->
<xsl:if test="contains( concat($currentPage/@path, ','), concat(',', @id, ',') )">
<xsl:attribute name="class">open</xsl:attribute>
</xsl:if>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
<xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level <= $maxLevelForSitemap]) > 0">
<ul>
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</ul>
</xsl:if>
</li>
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
is working on a reply...