Friday, July 3, 2015

Comment box with blog: Show comment count

I have updated the solution to be able to count the number of comments on a blog post. This modification is tested in SP2013 only. Parts of it may work for SP2010 as well, but this can not be guaranteed.

Follow the instructions in this post for the basic setup, and then follow these instructions to add the comment count.

Make the SPJS-CommentBox list visible

You must make the list “SPJS-CommentBox” visible to be able to add a lookup column from “Posts” to this list. Either use SharePoint designer (right click the list, select “Properties”, and uncheck “Hide from browser”), or use this tool: http://ift.tt/1o252KU

Add lookup field in the SPJS-CommentBox list

Add a lookup column named “ParentPostTitle” from “SPJS-CommentBox” to “Posts” like this:
IMG

Add lookup field in the Posts list

Add a lookup back to “SPJS-CommentBox” called “cBoxCount” like this – note the field “ParentPostTitle (Count Related):
IMG

Update the file “spjs-cBox_min.js” to v2.2.2 or later

Download the latest version here

Then update your function call like this:

var argObj = {
        "placeholderID":"cBox_A",
        "threadID":threadID,
        "blogMode":true, 
        "storeCommentsOnRootSite":false,
        ...
        ...
        ...

Note the setting “blogMode”:true”.

In the “Post” page you add the cBox code like this

IMG

In the Posts list you will see the count of comments like this

IMG

Please post any questions or comments in the forum: http://ift.tt/1C7hQHq


by Alexander Bautz via SharePoint JavaScripts

No comments:

Post a Comment