SharePoint 2010 Search: Show up all blog entries from different sites at one place

Think about the following scenario. You have to sites within your farm.

A: http://mysite

B: http://intranet

On site A you have several blogs written by your employees on their mysite. And on site B there are some project blogs on the intranet.

But now you want to have one site with all updates from the blogs around your farm. To reach this goal we just use the core result webpart. The results looks like this:

So, how to get this things done? Just follow the next few steps.

Create a content source for searching your site A and B

Go to the central administration on your SharePoint environment. Look for the content source “Local SharePoint Sites” and be sure that you have added your site A and B to the starting addresses.

Set a search scope for site A and B

To get all the results you want to show up on the target page, set a search scope called e.g. “blogposts”. You are able to set this scope also within your central administration.

Rule 1 for scope blogposts and site B

First define the Folder which contains the blogposts you want to search for.

Rule 2 for scope blogposts and site A

Also define another folder location to search for all your project blogs. In this case we refer to our mysite.

Rule 3 for scope blogposts and contentclass STS_ListItem_Posts

Now it becomes tricky. Set a rule to just filter the contentclass STS_ListItem_Posts. This is the class which identifies all blog posts. Be sure that you select “required”.

Start with a blank site

Now, after we have set the search scope and content type to find our blog posts we start with a blank page. Go to a blank site where you want to display the whole blog entries. Insert a core result webpart.

Set the store location properties

As store location we choose local search results and as scope we set it to blogposts.

Set the properties for the view

We just want to have a ordered list by change date. Also we just want to get the last 5 blog entries.

Set a fixed search parameter

To get results we have to enter a fixed keyword search. Just enter “contentclass:STS_ListItem_Posts” as parameter for search all blog posts within our scope.

First unformatted result looks like a standard search result

If everything works fine, you will get a result similar to the next screenshot. But now we want to customize it with a little bit XSL to get a better look and feel of your blog posts.

Customize the look and feel of our blog posts

Just open again the webpart settings of our core result webpart and go to the properties section where you are able to edit the XSL. Uncheck the option field to edit the standard XSL.

Now enter a custom XSL like this one here:



<xsl:stylesheet xmlns:x= "http://www.w3.org/2001/XMLSchema"
xmlns:d= "http://schemas.microsoft.com/sharepoint/dsp"
version= "1.0"
exclude-result-prefixes= "d xsl msxsl ddwrt xmlns x __designer WebControls asp ddwrt2"
xmlns:ddwrt= "http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:asp= "http://schemas.microsoft.com/ASPNET/20"
xmlns:__designer= "http://schemas.microsoft.com/WebParts/v2/DataView/designer"
xmlns:xsl= "http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl= "urn:schemas-microsoft-com:xslt"
xmlns:WebControls= "Microsoft.Sharepoint.WebControls"
xmlns:ddwrt2= "urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:template match="Result">
<xsl:variable name="blogPath">
<xsl:call -template name="getblogpath">
<xsl:with -param name="encodedPath" select="url" />
</xsl:call>
</xsl:variable>
<li class="blogListPost">
<!-- date box -->
<div class="blogListPostDate">
<div class="ms-postcalendardateboxtop" id="PostDateTopBox{generate-id()}"/>
<div class="ms-postcalendardateboxbottom" id="PostDateBottomBox{generate-id()}">
<div>
<xsl:value -of select="ddwrt:FormatDateTime(string(write),1033, 'MMMM dd')" />
</div>
</div>
</div>
<div class="blogListPostBlock">
<!-- Title -->
<h4>
<a style="color: #295AC6;">
<xsl:attribute name="href">
<xsl:value -of select="url"/>
</xsl:attribute>
<xsl:value -of select="title" />
</a>
</h4>
<!-- Date and Summary -->
<div class="blogListPostPostedDateAndSummary">
<span class="ms-PostFooter blogListPostPostedBy">
<b>Posted by
<xsl:value -of select="author" disable-output-escaping="yes" />
on
<xsl:value -of select="ddwrt:FormatDate(string(write),1027, 1)" />
</b>
</span>
<p class="ms-PostBody blogListPostBody">
<xsl:value -of select="hithighlightedsummary" disable-output-escaping="yes" />...
</p>
</div>
<!-- Blog links -->
</div>
</li>
</xsl:template>
<xsl:template match="TotalResults">
</xsl:template>
<xsl:template match="NumberOfResults">
</xsl:template>
<xsl:template name="getblogpath">
<xsl:param name="encodedPath"/>
<xsl:choose>
<xsl:when test="contains($encodedPath, '/')">
<xsl:value -of select="substring-before($encodedPath, '/')"/>/<xsl:call -template name="getblogpath">
<xsl:with -param name="encodedPath" select="substring-after($encodedPath, '/')" />
</xsl:call></xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<link rel="stylesheet" type="text/css">
<xsl:attribute name="href">
/_layouts/1033/styles/Themable/blog.css
</xsl:attribute>
</link>
<style type="text/css">
.blogList {list-style-type: none; padding:0;margin:0;}
.blogListPost {border-bottom:1px dashed #CCCCCC;padding:10px 0;margin:0;}
.blogListPost:hover {background-color:#F5F5F5;}
.blogListPostDate {float:left;width:90px;padding-left:20px;}
.blogListPostBlock {margin-left:110px;}
.blogListPostBlock h4 {padding:0;margin:0;}
.blogListPostPostedDateAndSummary {display:block;}
.blogListPostPostedBy { }
.blogListPostBody {padding-top:0px;padding-bottom:0;}
.blogListPostLinks {list-style-type:none;padding:0;}
.blogListPostLinksItem {display:inline;padding:0 10px 0 10px;border-right:Solid 1px #999999;}
.blogListPostLinksItem.last {border:none;}
</style> <ol class="blogList">
<xsl:apply -templates/>
</ol>
</xsl:template>
<!-- End of Stylesheet -->
</xsl:stylesheet>


After saving your new XSL the result looks like this.

..:: I like SharePoint ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Dennis de Vries About Dennis de Vries
Loving SharePoint, Social Media and like to work together with creative people all over the world.

2 comments on “SharePoint 2010 Search: Show up all blog entries from different sites at one place

  1. Hi,
    es funktioniert alles bis auf dass ich im XSL-Editor den oberen XLS-Code reinkopieren kann.

    “Nach dem Einfügen und abspeichern kommt folgene Meldung:
    Dieses Webpart kann nicht angezeigt werden. Öffnen Sie diese Webseite in einem mit Microsoft SharePoint Foundation kompatiblen HTML-Editor, z. B. in Microsoft SharePoint Designer, um dieses Problem zu behandeln. Falls das Problem weiterhin besteht, wenden Sie sich an Ihren Webserveradministrator.”

    Vielen Dank!

    • Hallo Lazrail,

      Bitte überprüfen Sie mal ob dieser link überhaupt bei Ihnen verfügbar ist und ersetzen diesen gegebenenfalls durch einen anderen Link


      /_layouts/1033/styles/Themable/blog.css

      Ansonsten habe ich Ihnen noch mal den Code angefügt. Vielleicht hat er sicht mit Formatierungen oder ähnliches schwer getan?























    • /







      /_layouts/1033/styles/Themable/blog.css



Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>

Please fill in the captcha: * Time limit is exhausted. Please reload CAPTCHA.