Getting the current position of a contentquery result
I am using a content query web part and want to have the first record appear differently than the other records that come after it. In order to do this you need something like the xsl position() function to determine if you are at the first element or not. You can't use position() from within your ItemStyles.xsl template though (it always returns a 1). So you need to make two quick changes to get this working.
First edit ContentQueryMain.xsl
Now edit ItemStyles.xsl
First edit ContentQueryMain.xsl
- find the OuterTemplate.CallItemTemplate template
- Find this block:
<xsl:when test="@Style='NewsCategoryItem'">
<xsl:apply-templates select="." mode="itemstyle">
[fix will go here]
</xsl:apply-templates>
</xsl:when> - Add this to the spot I've indicated above:
<xsl:with-param name="CurPos" select="$CurPosition" /> - Save ContentQueryMain.xsl
Now edit ItemStyles.xsl
- Add the following as the first item in your template:
<xsl:param name="CurPos" />
Comments