xsl-list
[Top] [All Lists]

[xsl] Conditional output and separators

2007-11-10 12:02:19
Hi,

I had hoped to introduce myself without a question but sadly the question
got here first! I'm currently investigating Umbraco which is an open source
ASP.Net CMS that uses XSLT heavily so I'm also having to brush up on it
quickly!

I've got stuck on the following scenario, I'm trying to list portfolio items
on a homepage, the theory being that first 3 are banners, the second 3 are
thumbnails. The html is as follows:

<ul>
            <!-Banners x 3 inserted here -->
</ul>
<ul class="hlist">
            <!-Thumbnails x 3 inserted here -->
</ul>

Now I've got it to list the 6 items but I'm not sure how to write in the:
</ul>
<ul class="hlist">

Without it throwing a wobbly. Could someone offer some insight please? Would
it be nested templates or something?

TIA

Tim

The XSLT I have so far:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]> 
<xsl:stylesheet   
                version="1.0"  
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";  
                xmlns:msxml="urn:Schemas-microsoft-com:xslt" 
                xmlns:umbraco.library="urn:umbraco.library" 
                exclude-result-prefixes="msxml umbraco.library"> 

<xsl:output method="xml" omit-xml-declaration="yes"/> 
<xsl:variable name="Banners">
                <xsl:choose>
                                <xsl:when test="/macro/Banners !=
''"><xsl:value-of select="/macro/Banners" /></xsl:when>
                                <xsl:otherwise>3</xsl:otherwise>
                </xsl:choose>
</xsl:variable>
<xsl:variable name="Thumbs">
                <xsl:choose>
                                <xsl:when test="/macro/Thumbs !=
''"><xsl:value-of select="/macro/Thumbs" /></xsl:when>
                                <xsl:otherwise>3</xsl:otherwise>
                </xsl:choose>
</xsl:variable>

<xsl:param name="currentPage"/> 

<xsl:template match="/">
<ul class="portList">
                
                <xsl:for-each
select="$currentPage/ancestor-or-self::node[(_at_)level=1]/descendant::node
[(_at_)nodeTypeAlias = 'PortfolioItemPage' and string(data
[(_at_)alias='umbracoNaviHide']) != '1']">
                                <xsl:sort select="@sortOrder"
data-type="number" order="ascending" />
                                
                                <xsl:choose>
                                                <xsl:when test="position()
&lt;= number($Banners) and ./data [(_at_)alias='ProjectImage'] != ''">
                                                                <li>
 
<a href="{umbraco.library:NiceUrl(@id)}"> 
 
<xsl:attribute name="title"><xsl:value-of select="data [(_at_)alias =
'MenuText']" /></xsl:attribute> 
 
<img src="{data [(_at_)alias='ProjectBanner']}" width="520" height="120"
alt="{data [(_at_)alias = 'MenuText']}" /><br />
 
<h3><xsl:value-of select="data [(_at_)alias = 'MenuText']"/></h3>
 
<p><xsl:value-of select="data [(_at_)alias = 'Intro']"
disable-output-escaping="yes"/></p>
 
</a>
                                                                </li> 
                                                </xsl:when>
                                                <xsl:when test="position()
&gt; number($Banners) and position() &lt;= number($Banners + $Thumbs) and
./data [(_at_)alias='ProjectImage'] != ''">
                                                                <li>
 
<a href="{umbraco.library:NiceUrl(@id)}"> 
 
<xsl:attribute name="title"><xsl:value-of select="data [(_at_)alias =
'MenuText']" /></xsl:attribute> 
 
<img src="{data [(_at_)alias='ProjectImage']}" width="88" height="88" alt="{data
[(_at_)alias = 'MenuText']}" />
 
</a>
                                                                </li> 
                                                </xsl:when>
                                </xsl:choose>
                </xsl:for-each>

</ul>
</xsl:template>

</xsl:stylesheet>



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] Conditional output and separators, Tim Gaunt <=