none
is there a way to add like button in a SP2013 page ? RRS feed

  • Question

  • Hello,

    Is there is a provision to add a like button (same as in facebook/twitter) in any of the SharePoint pages. We have an intranet SP2013 site.

    Would you be kind enough to let me know both options, viz. out of the box ( if any ), and custom development, and the level of effort required for each one, so i can get a resource ?

    Many thanks.

    Wednesday, March 8, 2017 7:34 AM

Answers

  • Hi,

    You could try to add the “Like” function in your page layout by JavaScript.

    function LikePage() {
        var like = false;
        var likeButtonText = $("a.LikeButton").text();
        if (likeButtonText != "") {
            if (likeButtonText == "Like")
                like = true;
    
            var aContextObject = new SP.ClientContext();
            EnsureScriptFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function () {
                Microsoft.Office.Server.ReputationModel.
                Reputation.setLike(aContextObject,
                    _spPageContextInfo.pageListId.substring(1, 37),
                    _spPageContextInfo.pageItemId, like);
    
                aContextObject.executeQueryAsync(
                    function () {
                        //alert(String(like));
                        GetLikeCount();
                    }, function (sender, args) {
                        //alert('F0');
                    });
            });
        }
    
    }

    Here is the thread for your reference.

    http://www.npatro.com/using-like-and-rating-functionality-in-sharepoint-2013-pages/

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, March 9, 2017 2:23 AM

All replies

  • Hi,

    You could try to add the “Like” function in your page layout by JavaScript.

    function LikePage() {
        var like = false;
        var likeButtonText = $("a.LikeButton").text();
        if (likeButtonText != "") {
            if (likeButtonText == "Like")
                like = true;
    
            var aContextObject = new SP.ClientContext();
            EnsureScriptFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function () {
                Microsoft.Office.Server.ReputationModel.
                Reputation.setLike(aContextObject,
                    _spPageContextInfo.pageListId.substring(1, 37),
                    _spPageContextInfo.pageItemId, like);
    
                aContextObject.executeQueryAsync(
                    function () {
                        //alert(String(like));
                        GetLikeCount();
                    }, function (sender, args) {
                        //alert('F0');
                    });
            });
        }
    
    }

    Here is the thread for your reference.

    http://www.npatro.com/using-like-and-rating-functionality-in-sharepoint-2013-pages/

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, March 9, 2017 2:23 AM
  • Thank you so much Lee, i studied, and tried this, and was able to achieve the functionality. 

    I really appreciate your help.

    Regards,

    prajK

    Wednesday, March 15, 2017 5:57 AM