Tuesday, March 13, 2012

Comparing Publishing Dates of Blog Posts

When displaying the list of published posts from a SharePoint Blog, you may want to hide certain elements such as the Publish Date div box if there are multiple posts on the same day. The XSL code below will compare the publish date of the post to the previous post and display or not display the div accordingly.

<xsl:variable name="PrevPosition" select="count(./preceding-sibling::*)" />
<xsl:if test="($Rows/Row[$PrevPosition]/@PublishedDate.MonthDayOnly !=
$thisNode/@PublishedDate.MonthDayOnly) or ($PrevPosition+1 = $FirstRow)">
...
</xsl:if>