<xsl:param name="currentPage"/> <!-- Input the documenttype you want here --> <xsl:variable name="level" select="2"/> <xsl:variable name="source" select="/macro/source" /> <!-- a content picker --> <xsl:template match="/"> <xsl:call-template name="drawNodes"> <xsl:with-param name="parent" select="umbraco.library:GetXmlNodeById($source)" /> </xsl:call-template> </xsl:template> <!-- funkcija koja se poziva rekurzivno --> <xsl:template name="drawNodes"> <!-- ulazni parametar za funkciju --> <xsl:param name="parent" /> <ul> <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> </ul> </xsl:template>
</xsl:stylesheet>
When it is executed it does nothing except for empy <ul></ul>. The problem is on the line
<xsl:for-each select="$parent/node">
it never goes bellow that line. If I try to insert some dummy code eg. <li>123</li> before that line it is shown in the page source. I'm really stucked with this. Anyone have a solution for this please help.
where 1234 is the node id (you get this from the properties tab) of the node you want to list everything beneath
i've not found another way to test this with the xslt visualiser and I'd be interested in any tips any one else has to test this
but this needs to be set as a parameter in your macro settings as a content picker called "source" to use it - you will then be prompted for the source you want to use when you add this macro to your template
2) is the content you are testing on published - also it is often worth republishing nodes if you have a problem like this - you can right click on the root node and choose "republish entire site" and this often solves annoying problems like this one
<!-- 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> </ul>
recursive function
What I want to do is to select all child nodes of selected page. The code for the xslt is bellow (it is a code from this link http://forum.umbraco.org/yaf_postst8993_List-entire-structure-from-changeable-source.aspx).
When it is executed it does nothing except for empy <ul></ul>. The problem is on the line
it never goes bellow that line. If I try to insert some dummy code eg. <li>123</li> before that line it is shown in the page source. I'm really stucked with this. Anyone have a solution for this please help.
i have to ask the obvious questions first
1) have you set a macro parameter for the source ? you can test if this may be the problem by replacing
with <xsl:variable name="source" select="1234" />
where 1234 is the node id (you get this from the properties tab) of the node you want to list everything beneath
i've not found another way to test this with the xslt visualiser and I'd be interested in any tips any one else has to test this
but this needs to be set as a parameter in your macro settings as a content picker called "source" to use it - you will then be prompted for the source you want to use when you add this macro to your template
2) is the content you are testing on published - also it is often worth republishing nodes if you have a problem like this - you can right click on the root node and choose "republish entire site" and this often solves annoying problems like this one
also
3) are you using version 4 or version 4.5 - due to the schema change the line for the count test may need to be changed
Using this in 4.5 the code inside the innter template needs to change to:
<ul>
<xsl:for-each select="$parent/* [@isDoc]">
<li><a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
<xsl:if test="count(./* [@isDoc]) > 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>
</ul>
Yes I have set the macro parameter for the source.
And yes your solution worked like it should.
Thank you.
you are most welcome :)
by a wonderfully serendipitous karmic moment
i was searching the forum for a solution to my own problem and this is actually also the solution to that
i want to give myself a high-five :D
is working on a reply...