Today we will see how to add custom like and comment functionality in SharePoint custom pages. For that I have developed one common web part/txt file using JQuery and REST api. Currently SharePoint is providing likes and rating functionality for the list items. I tried to use this but this was not required so I tried to develop this custom functionality for SharePoint online pages.
SharePoint-2013-Hosting1
You need to just add one content editor web part and add the below code into that web part. Below are the overall steps.Step 1
Create custom list in SharePoint having name “LikesList” to store all the likes given by the user. Add the below columns into it,

  • column name : LikeBy type : Person or Group
  • column name : CommentID type : Number
  • column name : PageURL type : Single line of text
Step 2
Create custom list in SharePoint having the name “CommentsList” to store all the comments added by user. Add the below columns into it,
  • column name : ParentCommentID type : Number
  • column name : CommentText type : Multiple lines of text
  • column name : PageURL type : Single line of text
  • column name : CommentBy type : Person or Group
Step 3
Now create one text file and add the below code into it and save that file.

Step 4
Create one web part page add your contents in to it. Add one more content editor web part -> edit web part -> give path of the txt file-> click on apply -> click on ok-> save the page -> publish it.

Step 5
After publishing the page you will see a comment box to add the comments and a like button to like the particular page.

Step 6
You can add the above code into any web part page using content editor and you will see the above functionality is working.