Friday, 16 May 2014

Promote your rating actions :Like a Page

In this post I will explain in details how to enable the like functionality for every page in your SharePoint site, and promote the like actions to the PromotedActions Delegate Control. 

In SharePoint 2013 a new DelegateControls are newly introduced like Sitesuitebar and promoted actions for a full list of the newly introduced place holders please check this blog post: 

First I will start with how to enable the ratings settings for your page library 
Navigate to your page library and via the ribbon click on the library settings , under the rating settings click on enable rating and choose likes. 




Now your site pages is available for rating , the out of the box rating actions can be found in the page library default view located in allitems.aspx page in our example we will try to provide an easier way to see the current pages like count and perform like and unlike actions from the page itself 

Create an empty SharePoint 2013 farm solution 


add new elements.xml file to it 

In the newly created elements.xml paste the below code which reference the LikePage user control
  
LikePage user control,will utilize the JavaScript object model and get he current page like count, also it detects whether the user already liked the page or not and it shows and hide the like actions based on that. 

This is how the control looks like  





 For complete source code please go to http://code.msdn.microsoft.com/Promote-your-rating-35fda760

Related Articles