How-To: Aggregate Blog comments using the Content Query WebPart

Aggregating blog posts using a content query webpart is rather simple. Even if you want to display meaningful teasers to the posts, you can easily change the layout/XSL of the content query webpart by following these guidelines: http://blog.henryong.com/2008/06/15/how-to-customize-the-content-query-web-part-xsl-to-aggregate-blog-posts/. (However, be aware that unclosed HTML-Tags might arise with this solution – this can blow your page layout completely!)

However, how to aggregate blog comments? I haven't found a "standard" solution, as the comments are using an own list type that is not listed in the content query element types drop down.

The workaround I found is fairly simple:

  • Create a content query webpart that aggergates blog posts.
  • Make sure that everything is configured just as you will want it for the comments.
  • Export the webpart and open it in your favourite text editor.
  • Change the following:
    • <property name="ServerTemplate" type="string">302</property> (302 is the list type of blog comments, 301 is for blog posts)
    • <property name="Title" type="string">Newest comments</property> (optional, this will be the title of your webpart)
  • Import the changed webpart definition file and add the webpart to your page.
  • Et voila…

Please note:

  • You cannot change any of the webpart properties within the browser. Every attempt will result in losing the "ServerTemplate" configuration.
  • The link to the comment might not be what you want: It will show the list item details, completely decoupled from the blog post. I'll try to figure out how to create a better link that points to the blog post (something like  Lists/Posts/Post.aspx?ID=1#Comments
  • I have no clue what will happen if you update your SharePoint installation or migrate to another version of SharePoint (likely: it will stop working :) )

Leave a Reply