Believe it or not the SharePoint ContentQuery Webpart, which is designed to display lists of information from our selected sources will not display a list of Blog entries. That is to say that it will not display it with out some simple modifications.
My first project, in which I had to learn this little trick, was to make a straight forward list of our blogs, on our home page.
Easy right? Ha ha. It is now that I know how. Follow these steps and you will be one step closer to having that site you have always wanted. (Or some other fun phrase there you like.)
1) Step one
open your site in Sharepoint Designer.
Locate this file and check it out.
Style Library > XSLStyleSheets > ItemStyle.xsl
2) Step Two
Go to the end of the file before the very last </xsl:stylesheet> Tag and insert the following definition.
********************************************
<xsl:template name="ListofBlogPosts" match="Row[@Style='ListofBlogPosts']" mode="itemstyle">
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="SafeImageUrl">
<xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
<xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
</xsl:call-template>
</xsl:variable>
<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:call-template>
</xsl:variable>
<xsl:variable name="LinkTarget">
<xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
</xsl:variable>
<div id="linkitem" class="item">
<xsl:if test="string-length($SafeImageUrl) != 0">
<div class="image-area-left">
<a href="{$SafeLinkUrl}" target="{$LinkTarget}">
<img class="image" src="{$SafeImageUrl}" alt="
{@ImageUrlAltText}" />
</a>
</div>
</xsl:if>
<div class="link-item">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<!-- Anonymous Freindly Link code -->
<xsl:text disable-output-escaping="yes"><![CDATA[<a href="
http://***YourURL.com***/Blogs/Lists/Posts/Post.aspx?ID=]]></xsl:text>
<xsl:value-of select="@ID"/>
<xsl:text disable-output-escaping="yes"><![CDATA[" Target="_self">]]></xsl:text>
<xsl:value-of select="$DisplayTitle"/>
<xsl:text disable-output-escaping="yes"><![CDATA[</a>]]></xsl:text>
<!-- End Anonymous Freindly Link code -->
<div class="description">
<xsl:value-of select="@Description" />
</div>
</div>
</div>
</xsl:template>
********************************************
3) Step three
Make sure you replace the Url "***YourURL.com***/Blogs" with the URL of your blog site.
then save the file and check in the changes.
4) Step four
On the page that you want to put your new list. Insert a ContentQuery WebPart.
On the menu for the webPart. (The edit link in the top right hand corner of the Webpart) Select "Modify shared webpart"
once the properties open on the right hand side of the page.
Select "Show items from the following lists" to "yourSiteName/Posts"
example "Blogs/Posts"
Now expand the presentation section using the + sign and under "Styles" change "ItemStyle" to "ListOfBlogPosts"
Save your changes, publish your page and enjoy your new list.
**PS.. Be sure to tune in next week when we'll here someone say "But it works on my computer! Grrrrrrr."
David Sullivan
Sharepoint Consultant