Hi Sledger (+ Rich) - just a quick FYI about how this works in XSLT:
Rich's solution will work just fine, though there's actually no need to count at all, because every selection will return a set of nodes that match the pattern; if no nodes are returned, the test will return false and the stuff inside won't be executed, so:
If-clause before iteration
Hello,
I'm writing a xslt that simply list childnodes like so:
<ul>
<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>
However, I need to wrap this in a if-clause so that the <ul>-tags does not get rendered if there is no child nodes. Should be simple? But how?
(I use the new schema...)
Not tested but should work ok
<xsl:if test="count($currentPage/* [@isDoc and string(umbracoNaviHide) != '1']) > 0">
<ul>
<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:if>
Rich
Hi Sledger (+ Rich) - just a quick FYI about how this works in XSLT:
Rich's solution will work just fine, though there's actually no need to count at all, because every selection will return a set of nodes that match the pattern; if no nodes are returned, the test will return false and the stuff inside won't be executed, so:
/Chriztian
Thanks to both of you. I'll go with ChriZtians solution since i suppose it performs better.
Thanks.
Chriztian's xslt solutions are always the best ones :)
Thanks Rich - I High-Fived yours in a feeble attempt to even out the evil takeover :-)
/Chriztian
is working on a reply...