I am new to umbraco and xslt and I am having a problem with rendering
the correct nodes to screen. My Content tree consists of:
Content
-Home
--Sub Node - Folder
---Archive Node - Folder -- node id=1379
----January - Folder
-------Page Node
-------Page Node
----February Node - Folder
-------Page Node
-------Page Node
What I require for each month to be rendered as the header and the
page nodes as a drop down list (This has been set up using a jquery
accordian).
The problem I am getting is that the January folder is being rendered
twice and the 4 page nodes are rendered underneath each January
heading. Its quite obvious I am missing the point somewhere with XSLT
and XPATH. Could some one tell me where I am going wrong please. My XSLT
file is:
Traversing nodes
Hi folks,
I am new to umbraco and xslt and I am having a problem with rendering the correct nodes to screen. My Content tree consists of:
Content
-Home
--Sub Node - Folder
---Archive Node - Folder -- node id=1379
----January - Folder
-------Page Node
-------Page Node
----February Node - Folder
-------Page Node
-------Page Node
What I require for each month to be rendered as the header and the page nodes as a drop down list (This has been set up using a jquery accordian).
The problem I am getting is that the January folder is being rendered twice and the 4 page nodes are rendered underneath each January heading. Its quite obvious I am missing the point somewhere with XSLT and XPATH. Could some one tell me where I am going wrong please. My XSLT file is:
<xsl:param name="currentPage"/>
<xsl:variable name="startnode" select="umbraco.library:GetXmlNodeById(1379)"/>
<xsl:template match="/">
<div class="event-details">
<h1><xsl:value-of select="$currentPage/@nodeName"/></h1>
<div class="function-wrapper">
<xsl:for-each select="$startnode/node">
<h2 class="trigger"><a href="#"><xsl:value-of select="$startnode/node/@nodeName"/></a></h2>
<div class="toggle_container">
<div class="block">
<ul class="list">
<xsl:for-each select="$startnode/node/node">
<li>
<a href="{umbraco.library:NiceUrl(@id)}" title="">
<xsl:if test="node!='false'">
<xsl:attribute name="title"><xsl:value-of select="@nodeName" /></xsl:attribute>
</xsl:if>
<xsl:value-of select="@nodeName" /></a>
</li>
</xsl:for-each>
</ul>
</div>
</div>
</xsl:for-each>
</div><!--end function-wrapper-->
</div><!--end event-details-->
</xsl:template>
Thank you
You for-each contains a reference to $startNode/node a few times, you should not repeat them over there. I just tested this version and it works fine:
Works a treat. Thank you for this. It has also got my head round what is needed.
Thanks again
No problem, would you be so kind as to mark my answer as the one that solved your problem? Thanks!
is working on a reply...