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
Hello All,
Thanks in advance.
I need to display the subnodes in the container page.
Mani page/node: Node1
Subnodes:
<xsl:template match="/"> start <xsl:for-each select="$currentPage/* [@isDoc][position() mod 3 = 1]"> first loop <div> <xsl:for-each select=". | following-sibling::*[not(position() >= 2)]"> second loop </xsl:for-each> </div> </xsl:for-each></xsl:template>
Hi Rao,
I think you can get this working by trying this. Assuming the first row will always consist of only 3 content nodes.
<xsl:template match="/"> <xsl:variable name="nodesToShow" select="3"/><!-- The fun starts here --> <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"> <xsl:choose> <xsl:when test="position()<= $nodesToShow"> First Row <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> - </xsl:when> <xsl:otherwise> Row 2 <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </xsl:otherwise></xsl:choose> </xsl:for-each>
Thanks for your response Fuji.
When I tried this, I am getting the result like
How are you displaying your content in a Div or Table Row?
//fuji
I tried both the ways...Thanks.
I prefer Div since i have more controls for my part....you could try something like that
<div style="float:left; width:600px;"> <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"> <xsl:choose> <xsl:when test="position()<= $nodesToShow"> <div style="float:left; width:190px; padding:0 5px; display:block;"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> a> div > xsl:when> <xsl:otherwise> <div style="float:left; width:190px; padding:0 5px; display:block;"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> a> div > xsl:otherwise> xsl:choose>xsl:for-each> div>
All the Child Div will float to the left and will thus automatically go to the next row. you can also use Ul List but basically its the same principal as div layout.
Regards
Thanks a lot Fuji. It worked.
But if user adds 3 more nodes, it's displaying the results like below:
Hey Rao,
Good to hear its working. Yes you might need to make some modifications to the Stylesheet for the other Content Row to display the values inline.
Am not sure if this can help but you can give this a try assuming only the first 3 nodes will always be displayed on the first row.
<xsl:variable name="nodesToShow" select="3"/> <xsl:variable name="changeRow" select="4"/><!-- The fun starts here --> <table border="1" cellpadding="0" cellspacing="0" width="800"> <tr> <td> <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']" > <xsl:if test="position()<= $nodesToShow"> <div style="float:left; width:auto; padding:0 5px; display:block;"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </div> </xsl:if> </xsl:for-each> </td> </tr> <tr> <td> <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']" > <xsl:if test="position()>= $changeRow"> <div style="float:left; width:auto; padding:0 5px; display:block;"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </div> </xsl:if> </xsl:for-each> </td> </tr> </table>
Thanks Fuji for all your help.
The example you have provided me did not worked as expected.
I have made some tweaks to my for-each loop based on what you have provided, now it's working as expected
Again thanks for all your help in resolving this.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
foreach loop in XSLT
Hello All,
Thanks in advance.
I need to display the subnodes in the container page.
Mani page/node: Node1
Subnodes:
Hi Rao,
I think you can get this working by trying this. Assuming the first row will always consist of only 3 content nodes.
<xsl:template match="/">
<xsl:variable name="nodesToShow" select="3"/>
<!-- The fun starts here -->
<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
<xsl:choose>
<xsl:when test="position()<= $nodesToShow">
First Row
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a> -
</xsl:when>
<xsl:otherwise>
Row 2
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
Thanks for your response Fuji.
When I tried this, I am getting the result like
How are you displaying your content in a Div or Table Row?
//fuji
I tried both the ways...Thanks.
I prefer Div since i have more controls for my part....you could try something like that
<div style="float:left; width:600px;">
<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
<xsl:choose>
<xsl:when test="position()<= $nodesToShow">
<div style="float:left; width:190px; padding:0 5px; display:block;">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
a>
div >
xsl:when>
<xsl:otherwise>
<div style="float:left; width:190px; padding:0 5px; display:block;">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
a>
div >
xsl:otherwise>
xsl:choose>
xsl:for-each>
div>
All the Child Div will float to the left and will thus automatically go to the next row.
you can also use Ul List but basically its the same principal as div layout.
Regards
//fuji
Thanks a lot Fuji. It worked.
But if user adds 3 more nodes, it's displaying the results like below:
Hey Rao,
Good to hear its working. Yes you might need to make some modifications to the Stylesheet for the other Content Row to display the values inline.
Am not sure if this can help but you can give this a try assuming only the first 3 nodes will always be displayed on the first row.
<xsl:variable name="nodesToShow" select="3"/>
<xsl:variable name="changeRow" select="4"/>
<!-- The fun starts here -->
<table border="1" cellpadding="0" cellspacing="0" width="800">
<tr>
<td>
<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']" >
<xsl:if test="position()<= $nodesToShow">
<div style="float:left; width:auto; padding:0 5px; display:block;">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</div>
</xsl:if>
</xsl:for-each>
</td>
</tr>
<tr>
<td>
<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']" >
<xsl:if test="position()>= $changeRow">
<div style="float:left; width:auto; padding:0 5px; display:block;">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</div>
</xsl:if>
</xsl:for-each>
</td>
</tr>
</table>
//fuji
Thanks Fuji for all your help.
The example you have provided me did not worked as expected.
I have made some tweaks to my for-each loop based on what you have provided, now it's working as expected
Again thanks for all your help in resolving this.
is working on a reply...