I have this code which is generating nested lists for navigation under a specific parent node. For some reason the <a href... is wrapping the lists oddly and itsn't actually closing after each <li> any ideas what I'm doing wrong?
<!-- Don't change this, but add a 'contentPicker' element to --> <!-- your macro with an alias named 'source' --> <xsl:variable name="source" select="1090"/>
Also, I found that the the second <a href is redunant. The code below, with your fix, links the whole list and nested lists appropriately.
<xsl:for-each select="$parent/node"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName" /> </a> <xsl:if test="count(./node) > 0"> <!-- this node has children, let's list them also -->
Improper nesting and linking of list
I have this code which is generating nested lists for navigation under a specific parent node. For some reason the <a href... is wrapping the lists oddly and itsn't actually closing after each <li> any ideas what I'm doing wrong?
<?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"/>
<!-- Don't change this, but add a 'contentPicker' element to -->
<!-- your macro with an alias named 'source' -->
<xsl:variable name="source" select="1090"/>
<xsl:template match="/">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="umbraco.library:GetXmlNodeById($source)" />
</xsl:call-template>
</xsl:template>
<xsl:template name="drawNodes">
<xsl:param name="parent" />
<ul>
<xsl:for-each select="$parent/node">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
<xsl:if test="count(./node) > 0">
<!-- this node has children, let's list them also -->
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="." />
</xsl:call-template>
</a>
</xsl:if>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
Hi Amir
This part of your code is wrong
the last closing </a> tag should be placed before your if test like below
Hope this helps
/Jan
Perfect, fixed. Thank you Jan!
Also, I found that the the second <a href is redunant. The code below, with your fix, links the whole list and nested lists appropriately.
<xsl:for-each select="$parent/node">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
<xsl:if test="count(./node) > 0">
<!-- this node has children, let's list them also -->
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="." />
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
is working on a reply...