I cant get a way out of this here. I have a list of items and the max list to be displayed is 6.
So what i need to achieve here is display the 1st item in a left floating div with all the title, description, images and the other 5 items in another div container with id="listChild" under which the content will display in UL list.
But can get this working since it its repeating the div id within it. How can i possilby write the div outside the ul list once only?
What you really should do, is to pre-sort the $items with a for-each inside a variable where you store the ids in simple elements. Then you can first ask for the 1st element and then for the rest - something like this:
Displaying a Div only once in xslt
Hi all,
I cant get a way out of this here. I have a list of items and the max list to be displayed is 6.
So what i need to achieve here is display the 1st item in a left floating div with all the title, description, images and the other 5 items in another div container with id="listChild" under which the content will display in UL list.
But can get this working since it its repeating the div id within it. How can i possilby write the div outside the ul list once only?
Here the div id childList should appear only once.
Hi Fuji,
This gets a little messy but it'll work all the while I'm sure you can understand what's happening:
<!-- Always cache stuff ! --> <xsl:variable name="items" select="umbraco.library:GetXmlNodeById($Items)/*[@isDoc][not(umbracoNaviHide = 1)]" /> <xsl:for-each select="$items"> <xsl:sort select="@createDate" order="descending" /> <xsl:choose> <xsl:when test="position() = 1"> <div id="newsSum"> <h1><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName" /></a></h1> </div> </xsl:when> <xsl:when test="position() = 2"> <div id="listChild"> <xsl:for-each select="$items"> <xsl:sort select="@createDate" order="descending" /> <xsl:if test="position() >= 2 and position() <= $MaxItems"> <ul> <li class="newsTitSum"><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName" /></a></li> <li class="newsDate"><xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'dd MMMM yyy')" /></li> <li class="newsTxtSum"><xsl:value-of select="umbraco.library:TruncateString(ItemDesc, 100, '...')" /></li> </ul> </xsl:if> </xsl:for-each> </div> </xsl:when> </xsl:choose> </xsl:if> </xsl:for-each>What you really should do, is to pre-sort the $items with a for-each inside a variable where you store the ids in simple elements. Then you can first ask for the 1st element and then for the rest - something like this:
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" /> <xsl:variable name="items" select="umbraco.library:GetXmlNodeById($Items)/*[@isDoc][not(umbracoNaviHide = 1)]" /> <!-- Build a sorted + filtered set --> <xsl:variable name="filteredProxy"> <xsl:for-each select="$items"> <xsl:sort select="@createDate" order="descending" /> <xsl:if test="position() <= $MaxItems"> <nodeId><xsl:value-of select="@id" /></nodeId> </xsl:if> </xsl:for-each> </xsl:variable> <xsl:variable name="filteredNodes" select="make:node-set($filteredProxy)" /> <xsl:template match="/"> <xsl:apply-templates select="$items[@id = $filteredNodes[1]]" mode="header" /> <xsl:for-each select="$filteredNodes[position() > 1]"> <xsl:apply-templates select="$items[@id = current()]" mode="items" /> </xsl:for-each> </xsl:template> <xsl:template match="*[@isDoc]" mode="header"> <div id="newsSum"> <h1><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName" /></a></h1> </div> </xsl:template> <xsl:template match="*[@isDoc]" mode="items"> <ul> <li class="newsTitSum"><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName" /></a></li> <li class="newsDate"><xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'dd MMMM yyy')" /></li> <li class="newsTxtSum"><xsl:value-of select="umbraco.library:TruncateString(ItemDesc, 100, '...')" /></li> </ul> </xsl:template>/Chriztian
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.