How to to retrieve and display Social Ratings in Content Query web part

Overview

In this post we will continue the discussion of accessing Social Data in Content Query web part that we started in the previous post. But this time we are going to customize Content Query web part in order to retrieve and display Social Ratings.  Our goal here to retrieve and display social ratings using the same way that they are being displayed  in List View.

When Ratings is enabled in List settings, the rating field is rendered in List View as shown below

ListViewWithRatings

and the customized Content Query web part for displaying Ratings control  will look like this

CBQWithSocialRatings

Prerequisites:

Implementation

So, lets start with the implementation of XSL stylesheet for rendering the Ratings control.

Social Ratings fields in SharePoint 2010

SharePoint 2010 comes with the following fields for Social Ratings:

  • AverageRating
  • RatingCount

For rendering AverageRating field in List View the  TEMPLATE\LAYOUTS\XSL\fldtypes_ratings.xsl is used. We will utilize templates from this file, but in order to make it work properly with CQWP, some modifications should be applied.

Ratings XSL stylesheet for CQWP

Templates definitions for the client side initialization and for rendering of of Ratings manager

Main XSL stylesheet

Custom ContentQueryMain.xsl is used, in which  the template for client side initialization of Ratings control is invoked

Source

Item XSL stylesheet

Custom ItemStyle.xsl is used, in which  the template for rendering Ratings control per page is invoked

Source

Ratings XSL Parameters

Parameter values are retrieved from resource file  and are passed via ParamaterBindings web part property

Let’s summarize.

In order to configure CQWP  for displaying Social Ratings , the following steps should be accomplished:

References

Advertisements

2 thoughts on “How to to retrieve and display Social Ratings in Content Query web part

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s