Resources for Using WordPress as a CMS

  5. (Custom Post-Type plugin, quick start-up than Pods, flutter, & CMS Press plugins)
  6. WordPress Optimization:
  7. General Collection of WP HowTOs:
  9. Designer Friendly Plugins:
  10. Edit-Flow Plugin.

Customizing the CQWP for Displaying Calendar Information

I was recently asked to display event information from a SharePoint (MOSS 2007 ) calendar in the following format:

Event Name

MM/D, hh:mm –  hh:mm

To get started, I read through Heather Solomon’s blog post on Customizing the Content Query Web Part and Custom Item Styles. I then read through this UK SharePoint group post, about adding the DDWRT namespace to the XSL styles sheet, which helped me figure out the necessary date and time transformations.  I also referenced this MSDN article on the functions in ddwrt namespace.

I modifed the Content Query Web Part as follows:

<property name=”CommonViewFields” type=”string”>EventDate,DateTime;EndDate,DateTime</property>

<property name=”DataColumnRenames” type=”string”>EventDate,DateTime;EndDate,DateTime</property>

I then Modifed the /Style Library/XSL Style Sheets/ItemStyle.xsl to include the following XSL Template:

<xsl:template name=”CenterCalendar” match=”Row[@Style=’CenterCalendar’]” mode=”itemstyle”>
<xsl:variable name=”SafeImageUrl”>
<xsl:call-template name=”OuterTemplate.GetSafeStaticUrl”>
<xsl:with-param name=”UrlColumnName” select=”‘ImageUrl'”/>
<xsl:variable name=”SafeLinkUrl”>
<xsl:call-template name=”OuterTemplate.GetSafeLink”>
<xsl:with-param name=”UrlColumnName” select=”‘LinkUrl'”/>
<xsl:variable name=”DisplayTitle”>
<xsl:call-template name=”OuterTemplate.GetTitle”>
<xsl:with-param name=”Title” select=”@Title”/>
<xsl:with-param name=”UrlColumnName” select=”‘LinkUrl'”/>
<xsl:variable name=”LinkTarget”>
<xsl:if test=”@OpenInNewWindow = ‘True'” >_blank</xsl:if>
<div id=”linkitem”>
<xsl:if test=”string-length($SafeImageUrl) != 0″>
<a href=”{$SafeLinkUrl}” target=”{$LinkTarget}”>
<img src=”{$SafeImageUrl}” alt=”{@ImageUrlAltText}”/>
<xsl:call-template name=”OuterTemplate.CallPresenceStatusIconTemplate”/>
<a href=”{$SafeLinkUrl}” target=”{$LinkTarget}” title=”{@LinkToolTip}”>
<xsl:value-of select=”$DisplayTitle”/>
<xsl:value-of select=”@Description” />
<xsl:value-of select=”ddwrt:FormatDateTime(string(@EventDate) ,1033 ,’dddd MM/dd/yyyy h:mm tt’)” />

<xsl:value-of select=”ddwrt:FormatDateTime(@EndDate ,1033 ,’ h:mm tt’)” />


The resulting CQWP looks like this, & is missing the start time:

Event #1
– 3:00 PM
Event #2
– 6:00 PM