9 Jun 2011

Add OOTB Rating Control in SharePoint 2010 Blog Site

Again, this is really bad I think Confused smile. Rating Control doesn’t exist in Blog template site in SharePoint 2010, even if you have activated Rating feature in Posts list. I think there’s a good solution out there in internet, but I have a different one. It’s not the best solution I think, but can be comparable. The easy way, but good enough.

Open SharePoint Designer 2010 and open your SharePoint 2010 Blog Site
image

Browse to All Files > Lists > Posts
image

image

Right click Post.aspx and click Edit File in Advanced Mode
image

Put that code (look at the footer of this post) between 2 XSLTListViewWebPart of Posts and Comments, maybe at line 221 like in the picture.
image

image

Code Snippet
  1. </ZoneTemplate>
  2. </WebPartPages:WebPartZone>
  3. <div style="padding-bottom: 10px; vertical-align:middle">
  4.     <div style="float:left;display: inline-block; margin-top: 2px; margin-right:10px">
  5.         Rate this post
  6.     </div>
  7.     <SharePoint:AverageRatingFieldControl FieldName="5a14d1ab-1513-48c7-97b3-657a5ba6c742" ControlMode="Display" runat="server"/>
  8. </div>
  9. <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="LeftFooter" Title="loc:LeftFooter" AllowPersonalization="false">
  10. <ZoneTemplate>

Save it, and one more thing to add,
image


Add this line at the top (maybe at the third line is a good position).

Code Snippet
  1. <%@ Register
  2.     Tagprefix="SharePoint"
  3.     Namespace="Microsoft.SharePoint.Portal.WebControls"
  4.     Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Save it, and you’re done. And, here’s the result,

image


See, I told you, it’s easy.

UPDATE 28 Jun 2012:
I laughed at myself, found that my article is not complete Laugh, not really easy to follow for everyone. Thanks for Anonymous (as always) though, you “told” me without saying anything that my article is not complete. Though I still confused, some people still can follow my article and said “thanks, great article”. Aaah… they maybe a SharePoint expert.

OK, here’s what happen when people are not able to add rating control, that’s because of these reasons below. Configure / do these actions is a MUST, no bargaining at all.Stress

  • You’re not paying for SharePoint Smile. Just kidding… but really serious, means that you’re using the free version of SharePoint called SharePoint Foundation 2010, which is not included Rating capabilities.
  • Configure your SharePoint User Profile Service Application.
  • Associate your SharePoint User Profile Service Application to Web Application where your MySite is hosted. Usually this done by default if you’re not planning to use custom settings, but worth to check.
  • It depends on a site collection feature, named SharePoint Server Publishing Infrastructure. Activate this by navigate to the top level site from your blog, by clicking Site Actions and then Site Settings, and find Go to top level site settings to navigate to the top level site (your MySite). Find Manage site collection features, and activate SharePoint Server Publishing Infrastructure feature.
  • It depends on a site feature named SharePoint Server Publishing. My suggest is to activate the site feature only on your Blog site. You can do this by navigate to your Blog site first, then clicking Site Actions and then Site Settings, and find Manage site features. Activate the SharePoint Server Publishing feature.
  • Enable Rating Settings on Posts list in your Blog site.

I got this from an article, reminds me of my mistake.

Again, hope it helps…. Sorry

29 komentar:

  1. So I added it and it works on the left pane not under each post :-( any hints?

    Cheers Rob

    BalasHapus
  2. The code must be in the right place. take a look carefuly at the line number at my post image. If you confuse where the code must be placed, you could switch to Split View Mode in SharePoint Designer.

    Hope it helps.

    BalasHapus
  3. Awesome post...someone said this post is an old one and not sure whether it would work...but then old is gold aint it? :)
    Thanks for the help.

    BalasHapus
    Balasan
    1. Thanks a lot, ARUN. I'm just trying to archive all the solutions in one blog whether I found it by myself or from some fellow blogger. Happy to help and thanks for stopping by...

      :-D

      Hapus
  4. Awsome and simple enough to follow. Thanks so much for sharing it..

    BalasHapus
  5. It works great but it better if the rating show up at the http://.../blog/default.aspx page. Can that be possible?

    BalasHapus
    Balasan
    1. AFAIK, you can't.
      Uniquely, AFAIK, this control only works when there's a SPContext.ListItem on. It means that wherever it'll be, won't work as long as no SPContext.ListItem.

      That's why when you provide the control's attribute, for SharePoint:AverageRatingFieldControl, no List Name and List Item provided, right? Just put it on the code, right?

      So, it's not possible, unless, you create your own control for this rating, which is very time consuming.

      Hope it helps.

      Hapus
  6. Ok- I am new to SHarepoint but I have followed the steps and I get unknown server tag SharePoint:AverageRatingFieldControl

    BalasHapus
    Balasan
    1. Did you add the tag for Microsoft.SharePoint.Portal.WebControls? The control originating from that Namespace, from Microsoft.SharePoint.Portal.DLL, so you must add it.

      Hapus
    2. Lines 1 and 2 and line 2 already contained the recommended code and i was unable to modify- I have included them below

      <%@ Page language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:webpartpageexpansion="full" meta:progid="SharePoint.WebPartPage.Document" %>

      <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

      Hapus
    3. Have you saved it? Have you publish it (if there's a publishing feature turned on)? Worth to check whether you turned on publishing feature or not.

      Hapus
  7. Hi! Any idea on why this might work in our QA environment and not in PROD? Are there any security or permissions settings we might look at?

    BalasHapus
    Balasan
    1. It's just a simple modification, no security settings. You might need to publish (if you've turned on publishing feature). Beyond that, no other settings.

      Hapus
  8. Do you know how to show total ratings field too? Can we just use the "RatingCountFieldControl" control similar as for average?

    http://msdn.microsoft.com/en-us/library/ee593603

    BalasHapus
    Balasan
    1. I never tried that before. But worth to try.

      Hapus
  9. Nevermind, I got it. This is the code I used.

    BalasHapus
    Balasan
    1. Code didn't show. Basically it's same code just use SharePoint:RatingCountFieldControl and for FieldName use b1996002-9167-45e5-a4df-b2c41c6723c7

      Hapus
  10. SHarepoint 2010 Blog site on the Post.aspx page - I added the Averagerating column to the comments list view webpart using Sharpoint designer but the column does not show up- what is causing the column to be hidden. I can see it in the code as FielRef

    BalasHapus
    Balasan
    1. What do you mean with "to the comments list view webpart"? If you mean by adding it inside list view webpart, of course it'll error somehow.
      What you can do is to add above the comments list view web part. ;)

      Hope it helps....

      Hapus
  11. I've been unable to figure out how to get this to work. In SharePoint Designer 2010, Lines 1-261 and lines 470 to end are highlighted in yellow, and do not allow editing.

    I'm a farm admin, so it's not a permission issue.

    any ideas?

    BalasHapus
    Balasan
    1. You just need to swing your sword and click "Edit in Advanced Mode" :-P

      That's a security feature that securing your SharePoint Designer from naughty fingers.

      Hapus
  12. Great Job! Have this working, was fairly easy to do. As a an added note, I also created a view of top rated for all blog entries, then added as a webpart so all posts can be seen by order of rating. Just a simple add for the users.

    BalasHapus
  13. Thanks so much! I tried so many methods, this one is the most clearly detailed and it worked for me!!

    BalasHapus

[give me your ideas, hopes, comments and compliments below...]
[aaand...... +1 if you need to....]