Comment counts

Forums Comment box for SharePoint Comment counts

Viewing 9 reply threads
  • Author
    Posts
    • #18076
      Juraj Benak
      Participant

      When a user subscribes to new comments, it creates a record in the list with ‘ID=99:subscription’ at the end but which counts towards the comments.

      So when 2 users subscribe, the posts says there are now two comments despite there being none.

      Is there a way of not including them in the count?

    • #18125
      Alexander Bautz
      Keymaster

      Hi,
      This was fixed in the April 19. 2017 release: https://spjsblog.com/commentbox-for-sharepoint/commentbox-change-log/

      Alexander

    • #18137
      Juraj Benak
      Participant

      Thanks Alexander – I do have the latest version but it still doesn’t seem to be working. Do I need to refresh or reindex? Or does it only work for new ones, not the old ones?

    • #18141
      Juraj Benak
      Participant

      I also wanted to add that I have blogmode enabled

    • #18154
      Alexander Bautz
      Keymaster

      Sorry, but I don’t understand. Does subscriptions still show in the count?

      Maybe your browser have the old version of the script cashed? – hover over the “cBox by SPJS” to see the version number.

      Alexander

    • #18158
      Juraj Benak
      Participant

      Yes it does. I hovered over the top and it shows 2.6.3

      Or perhaps it’s because of this script you’ve given me?

      
      
      <a href="//ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">//ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js</a>
      
      var cBoxCommentTicker = 100;
      setInterval(function(){
      	cBoxCommentTicker = 3000;
      	jQuery(".ms-blog-postBox").not(".commentBox").each(function(){
      		jQuery(this).addClass("commentBox");
      		var href = jQuery(this).find("a:first").attr("href");
      		var id = href.substring(href.lastIndexOf("/"));
      		getCBoxCommentCount(this,id);	
      	});
      },cBoxCommentTicker);
      
      function getCBoxCommentCount(elm,id){
      	jQuery.ajax({
      		"url": _spPageContextInfo.webServerRelativeUrl+"/_api/web/lists/getbytitle('SPJS-CommentBox')/items?$filter=substringof('"+id+"',Title)",
      		"method": "GET",
      		"headers": { "Accept": "application/json; odata=verbose" },
      		"success": function (data) {
      			jQuery(elm).find(".ms-blog-command-noLeftPadding").html(data.d.results.length+" comments");
      		},
      		"error": function (err) {
      			// console.log(err);
      		}
      	});
      }
    • #18190
      Alexander Bautz
      Keymaster

      Try modifying it like this:

      <a href="//ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">//ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js</a>
      
      var cBoxCommentTicker = 100;
      setInterval(function(){
      	cBoxCommentTicker = 3000;
      	jQuery(".ms-blog-postBox").not(".commentBox").each(function(){
      		jQuery(this).addClass("commentBox");
      		var href = jQuery(this).find("a:first").attr("href");
      		var id = href.substring(href.lastIndexOf("/"));
      		getCBoxCommentCount(this,id);	
      	});
      },cBoxCommentTicker);
      
      function getCBoxCommentCount(elm,id){
      	jQuery.ajax({
      		"url": _spPageContextInfo.webServerRelativeUrl+"/_api/web/lists/getbytitle('SPJS-CommentBox')/items?$filter=substringof('"+id+"',Title)",
      		"method": "GET",
      		"headers": { "Accept": "application/json; odata=verbose" },
      		"success": function (data) {
      			var count = 0;
      			jQuery.each(data.d.results,function(i,o){
      				if(o.Title.match("subscription") === null){
      					count += 1;
      				}
      			});
      			jQuery(elm).find(".ms-blog-command-noLeftPadding").html(count+" comments");
      		},
      		"error": function (err) {
      			// console.log(err);
      		}
      	});
      }
    • #18195
      Juraj Benak
      Participant

      Unfortunately that still shows incorrectly. I’ve tried using private mode but still the same result. Anything else I can try?

    • #18200
      Juraj Benak
      Participant

      Apologies, that did work! I just renamed the file and reuploaded the new one with the same name but SP automatically re-linked all CEWP to the old file so hence didn’t reflect!

      Thanks Alex!

    • #18204
      Alexander Bautz
      Keymaster

      No problem, I’m glad you got it working.

      Alexander

Viewing 9 reply threads
  • You must be logged in to reply to this topic.