Latest Entries

Splitting XSL for-each data into 2 columns. Two Ways!

On my mission to find a way to split a for-each statements results into 2 columns I came across two ways. one to do horizontal, the other vertical. these are the examples. The vertical option was a modified version of the code on this page, thanks! http://overture21.com/forum/comments.php?DiscussionID=378

Display Horizontal

A      B

C      D

E      F

Code

 
<xsl:for-each select="root/minimapproducts/item">
<li style="width: 45%;float: left;">
<a>
<xsl:attribute name="href">
<xsl:value-of select="/root/gendermix/cat" />/<xsl:value-of select="@url"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</li>
 
</xsl:for-each>
 

Vertial Layout

A      D

B      E

C      F

Code

 
<xsl:variable name="split" select="ceiling(count(/root/minimapproducts/item) div 2)" />
<ul class="mensLinks" style="width:45%; float:left;">
<xsl:for-each select="root/minimapproducts/item">
<xsl:if test="position() &amp;lt;= $split">
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="/root/gendermix/cat" />/<xsl:value-of select="@url"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</li>
 
</xsl:if>
</xsl:for-each>
</ul>
<ul class="mensLinks" style="width:45%; float:left;">
<xsl:for-each select="root/minimapproducts/item">
<xsl:if test="position() &amp;gt; $split">
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="/root/gendermix/cat" />/<xsl:value-of select="@url"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</li>
 
</xsl:if>
</xsl:for-each>
</ul>
 

Welcome

Okay so here is the start of what I want to be a log/portfolio of everything that I am doing with regards to developing websites and give people who are interested in using my skills or interested in how certain sites are progressing and my thoughts for them.



Copyright © 2004–2009. All rights reserved.

RSS Feed. This blog is proudly powered by Wordpress and uses Modern Clix, a theme by Rodrigo Galindez.