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 all,
I’ve been trying to get this to work for a while now.
I want to print out my navigation in two columns if the count of items exceeds 7. Creating a new div-class "megadropcol".
So far I got this to work – it prints out all items in just one column:
<!-- Drop Down Menu -->
<xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1']) > 0">
<div class="megadrop" style="display: none;">
<div class="megadropContent">
<div class="megadropcol">
<h3>Megadropheadline1</h3>
<ul>
<xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
<xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
<xsl:attribute name="class">current</xsl:attribute>
</xsl:if>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</div>
<!-- End of Drop Down Menu -->
I’m new to XSLT so bear with me J
Thanks in advance.
you could use something like <xsl:if test="position() < 7 "> to restrict the number of <li> items rendered out.
I've tried that one but no luck:
<!-- Drop Down Menu --> <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1']) > 0"> <div class="megadrop" style="display: none;"> <div class="megadropContent"> <!--Start less than 7--> <xsl:if test="position() <= 7 "> <div class="megadropcol"> <h3>Megadropheadline1</h3> <ul> <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"> <xsl:attribute name="class">current</xsl:attribute> </xsl:if> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul> </div> </xsl:if> <!--End less than 7--> <!--Start greater than 7--> <xsl:if test="position() > 7 "> <div class="megadropcol"> <h3>Megadropheadline1</h3> <ul> <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"> <xsl:attribute name="class">current</xsl:attribute> </xsl:if> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul> </div> </xsl:if> <!--End greater that 7--> </div> </div> </xsl:if> </li> <!-- End of Drop Down Menu -->
The reason that's not working is because you're putting the line
<xsl:if test="position() <=7> outside the <xsl:for-each loop/>
the position() function only works inside the for-each loop
Thank you :-) That worked.
If anyone want the solution:
<!--Start less than 7--> <div class="megadropcol"> <h3>Megadropheadline1</h3> <ul> <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']"> <xsl:if test="position() <= 7 "> <li> <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"> <xsl:attribute name="class">current</xsl:attribute> </xsl:if> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:if> </xsl:for-each> </ul> </div> <!--End less than 7--> <!--Start greater than 7--> <div class="megadropcol"> <h3>Megadropheadline1</h3> <ul> <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']"> <xsl:if test="position() >= 7 "> <li> <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"> <xsl:attribute name="class">current</xsl:attribute> </xsl:if> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:if> </xsl:for-each> </ul> </div> <!--End greater than 7-->
No worries.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Use two columns if items exceeds 7
Hi all,
I’ve been trying to get this to work for a while now.
I want to print out my navigation in two columns if the count of items exceeds 7. Creating a new div-class "megadropcol".
So far I got this to work – it prints out all items in just one column:
I’m new to XSLT so bear with me J
Thanks in advance.
you could use something like <xsl:if test="position() < 7 "> to restrict the number of <li> items rendered out.
I've tried that one but no luck:
The reason that's not working is because you're putting the line
<xsl:if test="position() <=7> outside the <xsl:for-each loop/>
the position() function only works inside the for-each loop
Thank you :-) That worked.
If anyone want the solution:
No worries.
is working on a reply...