Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

Conditional foreach in sitecore xsl & limiting results

Modified: 2009/08/10 10:25 by Vincevanm - Categorized as: Sitecore, XSL
In some Sitecore sites the For Each has "if" statements to filter the results. This works but performance wise it's better to use a conditional for-each.

Bad example: < xsl:for-each select="$newsroot/item" >

< xsl:if test="sc:fld('Created', .) != and @tid='{D6DEADF0-5172-4984-BCFD-101BCA8396E0}']" >

logic here

< /xsl:if>

< /xsl: for-each >

Best practice: < xsl:for-each select="$newsRoot/item
">

Best for practice for limiting results returned by the for each:

limitresults.txt

 © Evident Interactive BV