开发者

Multiple IntenseDebate Comment Counts

开发者 https://www.devze.com 2022-12-29 04:43 出处:网络
I just setup IntenseDebate on my b开发者_StackOverflowlog this evening and am, for the most part, pleased with it. One thing I did see is that they offered me a small snippet to show the current numbe

I just setup IntenseDebate on my b开发者_StackOverflowlog this evening and am, for the most part, pleased with it. One thing I did see is that they offered me a small snippet to show the current number of comments:

<script>
var idcomments_acct = 'abcdefgef12345678mykey8675309acdc';
var idcomments_post_id;
var idcomments_post_url;
</script>
<script type="text/javascript" 
        src="http://www.intensedebate.com/js/genericLinkWrapperV2.js"></script>

This is nice, but what I would like to do is have something similar on my archives page where many posts are listed - not just one. Presently the page looks like this:

  • Some Post Title

    Author Name

    Short abstract from this post...

  • Some Post Title

    Author Name

    Short abstract from this post...

I would like it to look like this:

  • Some Post Title

    Author Name

    Short abstract from this post...

    7 Comments

  • Some Post Title

    Author Name

    Short abstract from this post...

    3 Comments

But I'm not exactly sure how I can do this with IntenseDebate. Do they offer any sort of method to gather the total number of comments for multiple pages from a single page?


I've come up with a conceptual solution to my problem, which involves using the IntenseDebate API and adding some server-side scripting to the mix.

  1. If your database does not currently store comment counts for each entry, you should add a field for this. This number will be requested upon rendering the main page that shows all of our most recent posts.

  2. We'll want to write a small script that will live on the server and exist for nothing more than to change the comment count values for variou entries in our database. This can work by incrementing whatever initial value is there by 1, or by accepting a completely new number altogether.

  3. We want to create a local javascript function that will asynchronously invoke the aforementioned server-side script, updating our database. We'll want to invoke this javascript function via an action hook provided in the IntenseDebate API. Anytime a visitor posts a comment, the action hook will invoke our local Javascript function, which will in turn invoke our server-side function, which will update our database.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号