Online Training On SharePoint
                      

Friday 19 February 2010

Adding Rating Control on a Layout Page in SharePoint 2010

With SharePoint 2010 we can rate individual items which are stored in a library. It is not very intutive to rate the SharePoint Pages which are stored in page library. Users needs to go to Edit Properties and there they see the rating control from where they can rate. I wanted to show this on the page itself so that it is easy for the users to rate any page. For this we can add the SharePoint Rating Control on the Layout Page based on which the page is getting created. I will explain how to do this for the pages which are stored in a page library and are created using Body Only Page Layout:
1. Activate the rating feature for the page library from Settings -- Rating Settings:

2. Now using SharePoint Designer Open the Layout Pages folder and open the Body Only Page Layout.
3. Add the following Register directives at the top of this layout page:
<%@ Register Tagprefix="SharePointPortalControls" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
4.Add the AverageRatingFieldControl to the PlaceHolderMain content control:
<SharePointPortalControls:AverageRatingFieldControl id="PageRatingControl" FieldName="Rating (0-5)" runat="server"/>
Need to make sure that the FieldName must match the column name in the list.
(The code may not show properly in the Firefox)
5. It may be required to do a IIS reset.
6. Once this is done if you create a new page in SharePoint using this layout you will see that rating control will appear on the page and user can easily do the rating:

8 comments:

Unknown said...

How can we add this control in the Blogs site of the SharePoint 2010. I am working to add near the title of the blog on the Default.aspx page.

Reply will be helpful.

Unknown said...

Since blogs does not have a page layout the above will not work..For this you need to add the rating column in the Post Content Type and then in the Post.aspx file add the column as well. I will put a detailed post on this

Unknown said...

Thanks Manish for response. Well I added both controls Rating and No of Rating in the Post Content type. Now I ad also adding the controlto post.aspx page of the Posts library, but I cannot see the columns in the add lists of column in SharePoint Designer 2010. Is I am missing anything. Response will be helpful.

Unknown said...

Well i got it. I had added al the things.
1. Added in Post Content Type of the Blogs Site.
2. Added the above register tag and control tag in the Post.aspx page of Posts list in Blog site.

Its working Wow.
Thanks for your help.

Unknown said...

Hi,

Well I have added the control. Is there any way to add using XSL(blogs.xsl)?

Anonymous said...

Hi, i'm stuck exactly at the same position where BSukhwal is... trying to add the rating to a blog via XSL (because blog's default is xsl - btw. can anyone explain why this is??). is there already a solution somewhere??

Unknown said...

Well I am again stuck at same issue. Need some help. In the blog view I have to change the Author name with custom column 'Name'. Any Idea ?
Thanks
Bharat

Anonymous said...

Hi,
I have created custom list using Schema files in MOSS 2007. I have upgraded my package to SharePoint 2010 and trying to enable rating on those lists. Both rating columns are added but control is not displayed in the list. I mean no stars are displayed there in the list items.

Any clue on this behavior.

Related Posts with Thumbnails