Thursday, May 07, 2009

MOSS 2007 - CQWP: Item Count

Similar to the group header count (http://bryansgeekspeak.blogspot.com/2009/05/moss-2007-cqwp-row-count-and-group.html), we can get at the current item row count a bit easier. The row count is already tracked in "/Style Library/XSL Style Sheets/ContentQueryMain.xsl" via the CurPosition variable. That variable is even passed to the ItemStyle.xsl template for us. We only need to setup a param to catch that variable (passed into the ItemStyle.xsl template as the variable name "CurPos") and then use it in our output.

Here is a snip from ContentQueryMain.xsl showing where we pass in the variable:



From ItemStyle.xsl, here is an example of a "SkipRow1" template that does not display the first item, but displays all those after the first returned by the CQWP:



All you really need in your template is the param part:

<xsl:param name="CurPos" />

and then whatever test/output you need to make the page work. Here is an example if statement against the CurPos variable:


<xsl:if test="$CurPos &gt; 1">
....
</xsl:if>

No comments: