<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Peter Gerritsen&#039;s blog &#187; XSLT</title>
	<atom:link href="http://blog.petergerritsen.nl/tag/xslt/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.petergerritsen.nl</link>
	<description>about .Net and SharePoint development</description>
	<lastBuildDate>Wed, 28 Jul 2010 08:28:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Displaying calendar items in an ItemStyle</title>
		<link>http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 14:05:21 +0000</pubDate>
		<dc:creator>Peter Gerritsen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/</guid>
		<description><![CDATA[We frequently get the question to display the next x upcoming events in a rollup webpart. A content query web part is very suitable for this, but you will needa custom ItemStyle. Below you will find the xsl to display events in the following format: The custom itemstyle checks for the difference between all day [...]<p><a href="http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/">Displaying calendar items in an ItemStyle</a> is a post from: <a href="http://blog.petergerritsen.nl">Peter Gerritsen&#039;s blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>
We frequently get the question to display the next <em>x</em> upcoming events in a rollup webpart. A content query web part is very suitable for this, but you will needa custom ItemStyle. Below you will find the xsl to display events in the following<br />
format:
</p>
<p>
<a  href="http://blog.petergerritsen.nl/wp-content/uploads/snipping16.png" class="thickbox no_icon" rel="gallery-547"><img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blog.petergerritsen.nl/wp-content/uploads/snipping17.png" width=315 height=73></a>
</p>
<p>
The custom itemstyle checks for the difference between all day events, events that span multiple days and checks for start and end times.
</p>
<p>
To use this itemstyle you will need to add EventDate and EndDate to the CommonViewFields and reference the ddwrt namespace in the top of your xsl:
</p>
<pre class="brush: xslt">xmlns:ddwrt=&quot;http://schemas.microsoft.com/WebParts/v2/DataView/runtime&quot;</pre>
<p>
And finally here’s the itemstyle:
</p>
<pre class="brush: xslt">
&lt;xsl:template name=&quot;CalendarEvent&quot; match=&quot;Row[@Style=&#039;CalendarEvent&#039;]&quot; mode=&quot;itemstyle&quot;&gt;
         &lt;xsl:variable name=&quot;SafeImageUrl&quot;&gt;
            &lt;xsl:call-template name=&quot;OuterTemplate.GetSafeStaticUrl&quot;&gt;
                &lt;xsl:with-param name=&quot;UrlColumnName&quot; select=&quot;&#039;ImageUrl&#039;&quot;/&gt;
            &lt;/xsl:call-template&gt;
        &lt;/xsl:variable&gt;
        &lt;xsl:variable name=&quot;SafeLinkUrl&quot;&gt;
            &lt;xsl:call-template name=&quot;OuterTemplate.GetSafeLink&quot;&gt;
                &lt;xsl:with-param name=&quot;UrlColumnName&quot; select=&quot;&#039;LinkUrl&#039;&quot;/&gt;
            &lt;/xsl:call-template&gt;
        &lt;/xsl:variable&gt;
        &lt;xsl:variable name=&quot;DisplayTitle&quot;&gt;
            &lt;xsl:call-template name=&quot;OuterTemplate.GetTitle&quot;&gt;
                &lt;xsl:with-param name=&quot;Title&quot; select=&quot;@Title&quot;/&gt;
                &lt;xsl:with-param name=&quot;UrlColumnName&quot; select=&quot;&#039;LinkUrl&#039;&quot;/&gt;
            &lt;/xsl:call-template&gt;
       &lt;/xsl:variable&gt;
          &lt;xsl:variable name=&quot;LinkTarget&quot;&gt;
             &lt;xsl:if test=&quot;@OpenInNewWindow = &#039;True&#039;&quot; &gt;_blank&lt;/xsl:if&gt;
       &lt;/xsl:variable&gt;
       &lt;xsl:variable name=&quot;MultiDayEvent&quot;&gt;
           &lt;xsl:choose&gt;
               &lt;xsl:when test=&quot;starts-with(@EndDate,substring(@EventDate, 0, 11))&quot;&gt;
                   0
               &lt;/xsl:when&gt;
               &lt;xsl:otherwise&gt;
                   1
               &lt;/xsl:otherwise&gt;
           &lt;/xsl:choose&gt;
       &lt;/xsl:variable&gt;
       &lt;xsl:variable name=&quot;StartTimeIsEndTime&quot;&gt;
           &lt;xsl:choose&gt;
               &lt;xsl:when test=&quot;contains(@EndDate,substring(@EventDate, 11, 9))&quot;&gt;
                   1
               &lt;/xsl:when&gt;
               &lt;xsl:otherwise&gt;
                   0
               &lt;/xsl:otherwise&gt;
           &lt;/xsl:choose&gt;
       &lt;/xsl:variable&gt;
       &lt;xsl:variable name=&quot;DisplayDate&quot;&gt;
           &lt;xsl:choose&gt;
               &lt;xsl:when test=&quot;$MultiDayEvent = 0&quot;&gt;
                   &lt;xsl:choose&gt;
                       &lt;xsl:when test=&quot;@fAllDayEvent = 0&quot;&gt;
                        &lt;xsl:choose&gt;
                               &lt;xsl:when test=&quot;$StartTimeIsEndTime = 1&quot;&gt;
                                   &lt;xsl:value-of select=&quot;ddwrt:FormatDateTime(string(@EventDate) ,1043 ,&#039;dd-MM-yyyy H:mm&#039;)&quot; /&gt;
                               &lt;/xsl:when&gt;
                               &lt;xsl:otherwise&gt;
                                   &lt;xsl:value-of select=&quot;ddwrt:FormatDateTime(string(@EventDate) ,1043 ,&#039;dd-MM-yyyy H:mm&#039;)&quot; /&gt; - &lt;xsl:value-of select=&quot;ddwrt:FormatDateTime(string(@EndDate) ,1043 ,&#039;H:mm&#039;)&quot; /&gt;
                               &lt;/xsl:otherwise&gt;
                           &lt;/xsl:choose&gt;
                       &lt;/xsl:when&gt;
                       &lt;xsl:otherwise&gt;
                        &lt;xsl:value-of select=&quot;ddwrt:FormatDateTime(string(@EventDate) ,1043 ,&#039;dd-MM-yyyy&#039;)&quot; /&gt;
                    &lt;/xsl:otherwise&gt;
                   &lt;/xsl:choose&gt;
               &lt;/xsl:when&gt;
               &lt;xsl:otherwise&gt;
                   &lt;xsl:choose&gt;
                       &lt;xsl:when test=&quot;@fAllDayEvent = 0&quot;&gt;
                           &lt;xsl:value-of select=&quot;ddwrt:FormatDateTime(string(@EventDate) ,1043 ,&#039;dd-MM-yyyy H:mm&#039;)&quot; /&gt; - &lt;xsl:value-of select=&quot;ddwrt:FormatDateTime(string(@EndDate) ,1043 ,&#039;dd-MM-yyyy H:mm&#039;)&quot; /&gt;
                       &lt;/xsl:when&gt;
                       &lt;xsl:otherwise&gt;
                           &lt;xsl:value-of select=&quot;ddwrt:FormatDateTime(string(@EventDate) ,1043 ,&#039;dd-MM-yyyy&#039;)&quot; /&gt; - &lt;xsl:value-of select=&quot;ddwrt:FormatDateTime(string(@EndDate) ,1043 ,&#039;dd-MM-yyyy&#039;)&quot; /&gt;
                       &lt;/xsl:otherwise&gt;
                   &lt;/xsl:choose&gt;
               &lt;/xsl:otherwise&gt;
           &lt;/xsl:choose&gt;
       &lt;/xsl:variable&gt;
       &lt;a href=&quot;{$SafeLinkUrl}&quot; target=&quot;{$LinkTarget}&quot; title=&quot;{@LinkToolTip}&quot;&gt;
            &lt;xsl:value-of select=&quot;$DisplayTitle&quot;/&gt;
        &lt;/a&gt;
        &lt;xsl:text&gt; - &lt;/xsl:text&gt;&lt;xsl:value-of select=&quot;$DisplayDate&quot;/&gt;&lt;br/&gt;
    &lt;/xsl:template&gt;
</pre>
<!-- RO Social Bookmarks BEGIN --><div class="social_bookmark"><em>Bookmark to:</em><br /><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home?status=http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/" title="Add 'Displaying calendar items in an ItemStyle' to Twitter"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/twitter.png" title="Add 'Displaying calendar items in an ItemStyle' to Twitter" alt="Add 'Displaying calendar items in an ItemStyle' to Twitter" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.myspace.com/Modules/PostTo/Pages/?t=Displaying+calendar+items+in+an+ItemStyle&#038;c=http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/" title="Add 'Displaying calendar items in an ItemStyle' to MySpace"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/myspace.png" title="Add 'Displaying calendar items in an ItemStyle' to MySpace" alt="Add 'Displaying calendar items in an ItemStyle' to MySpace" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/&#038;title=Displaying+calendar+items+in+an+ItemStyle" title="Add 'Displaying calendar items in an ItemStyle' to Del.icio.us"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/delicious.png" title="Add 'Displaying calendar items in an ItemStyle' to Del.icio.us" alt="Add 'Displaying calendar items in an ItemStyle' to Del.icio.us" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&#038;url=http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/&#038;title=Displaying+calendar+items+in+an+ItemStyle" title="Add 'Displaying calendar items in an ItemStyle' to digg"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/digg.png" title="Add 'Displaying calendar items in an ItemStyle' to digg" alt="Add 'Displaying calendar items in an ItemStyle' to digg" /></a><br /><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/share.php?u=http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/&#038;t=Displaying+calendar+items+in+an+ItemStyle" title="Add 'Displaying calendar items in an ItemStyle' to FaceBook"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/facebook.png" title="Add 'Displaying calendar items in an ItemStyle' to FaceBook" alt="Add 'Displaying calendar items in an ItemStyle' to FaceBook" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/" title="Add 'Displaying calendar items in an ItemStyle' to Technorati"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/technorati.png" title="Add 'Displaying calendar items in an ItemStyle' to Technorati" alt="Add 'Displaying calendar items in an ItemStyle' to Technorati" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/&#038;title=Displaying+calendar+items+in+an+ItemStyle" title="Add 'Displaying calendar items in an ItemStyle' to Stumble Upon"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/stumbleupon.png" title="Add 'Displaying calendar items in an ItemStyle' to Stumble Upon" alt="Add 'Displaying calendar items in an ItemStyle' to Stumble Upon" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&#038;output=popup&#038;bkmk=http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/&#038;title=Displaying+calendar+items+in+an+ItemStyle" title="Add 'Displaying calendar items in an ItemStyle' to Google Bookmarks"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/google.png" title="Add 'Displaying calendar items in an ItemStyle' to Google Bookmarks" alt="Add 'Displaying calendar items in an ItemStyle' to Google Bookmarks" /></a></div>
<!-- RO Social Bookmarks END --><p><a  href="http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/">Displaying calendar items in an ItemStyle</a> is a post from: <a  href="http://blog.petergerritsen.nl">Peter Gerritsen&#039;s blog</a></p>
<div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.petergerritsen.nl%2F2009%2F07%2F29%2Fdisplaying-calendar-items-in-an-itemstyle%2F&amp;layout=standard&amp;show_faces=false&amp;width=320&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:320px;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://blog.petergerritsen.nl/2009/07/29/displaying-calendar-items-in-an-itemstyle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
