Developer forum

Forum » Templates » Get only active child nodes

Get only active child nodes


Reply
When doing an xslt menu I whant to check if the node has any child nodes that are avtive and should be included in the menu. I have used the @ChildCount but it counts all nodes regardless of if the are to be included in the menu or not. How can I count only active child nodes?

Replies

 
Reply
Hi Paul

You can do like this '.[page[@Active='True']]'

This checks if the current node has page-childnodes with a True Active attribute.

// Sebastian
 
Reply
Hi

Sorry to sneak in like this... we have the same problem with our DD-menu.
We tried something like <xsl:if test="@ChildCount > '0' and .[page[@Active='True']]' ">,
but got one of those horrible xslt errors, could you spell it out for us please?

My XSLT knowledge is pretty mediocre.

-thanks
 
Reply
Try it like this:
<xsl:if test="@ChildCount &gt; '0' and .[Page[@Active='True']]">
Translation: Test if the attribute ChildCount of the current element is greater than 0, and if the current element has any childnodes named Page where the Active attribute is True

Or like this:
<xsl:if test="Page[@Active='True']">
Translation: Check if the current element has any childnodes named Page where the attribute Active is true

These 2 examples if's should check for the exact same thing though example 2 is a lot more simple.

 

You must be logged in to post in the forum