Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi there...
I'm creating this navigation in xslt, and I'm using an unordered list (ul>li) to do this.
<xsl:if test="count(child::*) > 0"> <ul> <xsl:for-each select="$startItem/*[@isDoc and name() !='IntranetFolder']"> <xsl:variable name="leftnav" select="current()/hideFromLeftMenu"/> <xsl:if test="($leftnav != '1')"> <li>
the above works , as long as the "ul" has children that have the hideFromLeftMenu set to false ('0').
I was wondering, if it is possible to check for the hideFromLeftMenu before the xsl:for-each loop ? Maybe check for it in the count?
Best regardsMartin
Hi Martin,
Rule of thumb is to test with the same conditions - but you can use an intermediate variable to improve readability (and remove duplication), e.g.:
<xsl:variable name="nodes" select="$startItem/*[@isDoc][not(self::IntranetFolder)][not(hideFromLeftMenu = 1)]" /> <xsl:if test="$nodes"> <ul> <xsl:for-each select="$nodes"> <li> <!-- etc... --> </li> </xsl:for-each> </ul> </xsl:if>
/Chriztian
I'm not sure .... I'm only interested in printing the <ul> if count(children) > 0 and at least one of the children has hideFromLeftMenu = 0 :)
Would the above solution work for this scenario?
It seems like your solution worked :D
Thanks alot
Best regardsMartin.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
XSLT Navigation
Hi there...
I'm creating this navigation in xslt, and I'm using an unordered list (ul>li) to do this.
<xsl:if test="count(child::*) > 0">
<ul>
<xsl:for-each select="$startItem/*[@isDoc and name() !='IntranetFolder']">
<xsl:variable name="leftnav" select="current()/hideFromLeftMenu"/>
<xsl:if test="($leftnav != '1')">
<li>
the above works , as long as the "ul" has children that have the hideFromLeftMenu set to false ('0').
I was wondering, if it is possible to check for the hideFromLeftMenu before the xsl:for-each loop ? Maybe check for it in the count?
Best regards
Martin
Hi Martin,
Rule of thumb is to test with the same conditions - but you can use an intermediate variable to improve readability (and remove duplication), e.g.:
/Chriztian
I'm not sure .... I'm only interested in printing the <ul> if count(children) > 0 and at least one of the children has hideFromLeftMenu = 0 :)
Would the above solution work for this scenario?
It seems like your solution worked :D
Thanks alot
Best regards
Martin.
is working on a reply...