The site root "The Patient Experience" will have no left hand navigation, but first-level sub-pages beneath it will. Right now the only sub-page is "Patient and Family Centered Care", but there will be others.
So here's what I'd like to do. Each page that is one level below the root should include a left hand navigation that shows itself plus its children in a single-level list. Therefore once a visitor clicks on "Patient and Family-Centered Care", from the root, the subnav markup should be:
<ul id="contextNav">
<li><a href="/patient-and-family-centered-care/" class="currentPage">Patient and Family Centered Care</a></li>
<li><a href="/patient-and-family-centered-care/smh-mission-and-vision.aspx">SMH Mission and Vision</a></li>
<li><a href="/patient-and-family-centered-care/our-principles-of-patient-and-family-centered-care.aspx">Our Principles of Patient- and Family-Centered Care</a></li>
</ul>
Once a visitor clicks on "SMH Mission and Vision" the markup should be:
<ul id="contextNav">
<li><a href="/patient-and-family-centered-care/">Patient and Family Centered Care</a></li>
<li><a href="/patient-and-family-centered-care/smh-mission-and-vision.aspx" class="currentPage">SMH Mission and Vision</a></li>
<li><a href="/patient-and-family-centered-care/our-principles-of-patient-and-family-centered-care.aspx">Our Principles of Patient- and Family-Centered Care</a></li>
</ul>
Please note that I do NOT want this...
<ul id="contextNav">
<li><a href="/patient-and-family-centered-care/">Patient and Family Centered Care</a>
<ul>
<li><a href="/patient-and-family-centered-care/smh-mission-and-vision.aspx" class="currentPage">SMH Mission and Vision</a></li>
<li><a href="/patient-and-family-centered-care/our-principles-of-patient-and-family-centered-care.aspx">Our Principles of Patient- and Family-Centered Care</a></li>
</ul>
</li>
</ul>
So here's my XSL, which is basically the default helper XSL:
<xsl:variable name="level" select="2"/>
<xsl:template match="/">
<!-- The fun starts here -->
<ul id="contextNav">
<!-- Home node added here -->
<li>
<a href="/">Home</a>
</li>
<!-- Loop through site -->
<xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id">
<!-- we're under the item - you can do your own styling here -->
<xsl:attribute name="class">currentPage</xsl:attribute>
</xsl:if>
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
I hope someone can help me with what I'm trying to do here. XSL is confusing as heck to me and the Umbraco schema doesn't make it any easier.
<ul> <!-- write out the parent link manually --> <li><a href="{umbraco.library:NiceUrl($startNode/@id)}"><xsl:value-of select="$startNode/@nodeName"/></a></li>
<!-- write out the sibling links as normal --> <xsl:for-each select="$startNode/* [@isDoc]"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id"> <!-- we're under the item - you can do your own styling here --> <xsl:attribute name="class">currentPage</xsl:attribute> </xsl:if> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul>
System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
Here we go again... subnavigation in XSLT
Here is my content node tree:
The site root "The Patient Experience" will have no left hand navigation, but first-level sub-pages beneath it will. Right now the only sub-page is "Patient and Family Centered Care", but there will be others.
So here's what I'd like to do. Each page that is one level below the root should include a left hand navigation that shows itself plus its children in a single-level list. Therefore once a visitor clicks on "Patient and Family-Centered Care", from the root, the subnav markup should be:
Once a visitor clicks on "SMH Mission and Vision" the markup should be:
Please note that I do NOT want this...
So here's my XSL, which is basically the default helper XSL:
I hope someone can help me with what I'm trying to do here. XSL is confusing as heck to me and the Umbraco schema doesn't make it any easier.
Hi,
I would probably do something like this:
-Tom
Hmmm...
That gave me this dreaded error:
Hi Alex
Try checking the "skip error checking" - it's because the XSLT processor does not know the value if the id before runtime probably.
Hope this helps.
/Jan
Hi Alex,
Try this set of templates and tweak to your liking:
/Chriztian
I keep telling myself I'm going to learn to use templates properly someday... :)
@Tom: You'll like 'em :-) They're what XSLT is all about. Really :-)
/Chriztian
Chriztian,
You solved it for me. Thank you so much!
is working on a reply...