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
Hi i currently has a side navigation which renders the children of the current node
But..
i occationaly get a current node which has no children and end up with an empty sidenavigation
What i need is a sidenavigation which if the it has no children renders all the nodes on the same level as the current node
ie
home
-----services
--------------service a
--------------service b
--------------service c
-----contact
----Products
--------------Product a
--------------Product b
--------------Product c
so if i were on the services page
services a b and c would render
for contact(no children) if render services and products
products
product a b and c would render
this is my current xslt
<?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:template match="/"><!-- The fun starts here --><ul class="section menu"><xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li></xsl:for-each></ul></xsl:template></xsl:stylesheet>
please help my minds gone to mush
Hi Neil
Could you maybe try something like this:
<xsl:template match="/"><!-- The fun starts here --><ul class="section menu"> <xsl:choose> <xsl:when test="count($currentPage/* [@isDoc and string(umbracoNaviHide) != '1']) > 0"> <xsl:apply-templates select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"></xsl:apply-templates> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="$currentPage/../* [@isDoc and string(umbracoNaviHide) != '1']"></xsl:apply-templates> </xsl:otherwise> </xsl:choose></ul></xsl:template><xsl:template match="* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li></xsl:template>
/Kim A
No Joy :(
its not rendering anything, i think its had an issue with there being two when closing tags
thanks for trying.
</xsl:when>
changed to this still nothing
This should work:
<xsl:template match="/"> <!-- The fun starts here --><ul class="section menu"> <xsl:choose> <xsl:when test="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"> <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"> <xsl:call-template name="listitem"> <xsl:with-param name="node" select="current()"> </xsl:call-template> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:for-each select="$currentPage/../* [@isDoc and string(@id) != string($currentPage/@id) and string(umbracoNaviHide) != '1']"> <xsl:call-template name="listitem"> <xsl:with-param name="node" select="current()"> </xsl:call-template> </xsl:for-each> </xsl:otherwise> </xsl:choose> </ul> </xsl:template> <xsl:template name="listitem"> <xsl:param name="node" /> <li> <a href="{umbraco.library:NiceUrl($node/@id)}"> <xsl:value-of select="$node/@nodeName"/> </a> </li></xsl:template>
This worked a treat, cheers. you truely are the stuff of legend.
Thanks.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Child / Parent Side Navigation
Hi i currently has a side navigation which renders the children of the current node
But..
i occationaly get a current node which has no children and end up with an empty sidenavigation
What i need is a sidenavigation which if the it has no children renders all the nodes on the same level as the current node
ie
home
-----services
--------------service a
--------------service b
--------------service c
-----contact
----Products
--------------Product a
--------------Product b
--------------Product c
so if i were on the services page
services a b and c would render
for contact(no children) if render services and products
products
product a b and c would render
this is my current xslt
<?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:template match="/">
<!-- The fun starts here -->
<ul class="section menu">
<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
please help my minds gone to mush
Hi Neil
Could you maybe try something like this:
/Kim A
No Joy :(
its not rendering anything, i think its had an issue with there being two when closing tags
thanks for trying.
changed to this still nothing
This should work:
This worked a treat, cheers. you truely are the stuff of legend.
Thanks.
is working on a reply...