Integrating Disqus into Graffiti CMS

written by Andrew Tobin on Friday, December 07 2007

Edit: If you've come here to add Disqus to Graffiti try out my Chalk plug-in - Adding Disqus to Graffiti CMS (Take 2)

It means a little less coding into your theme to handle adding the system!

So one thing I've been noticing lately is the interest in commenting system Disqus. Scoble has been talking about it and Dave Winer uses it over at http://www.scripting.com/

Disqus is a commenting engine which allows you to track your comments between sites, provides some spam checking and extra features and tracks your login between sites as well.

To integrate it into Graffiti is incredibly easy, it just means a few theme modifications!

For example using my theme here, which is Missing Pieces by Rich Mercer, what I would need to do is edit the index.view file located at ~/files/themes/the missing piece/

I would need to comment out the line: $macros.CommentUrl($post, "%{anchor='comments', class='comments'}")

And instead add the Disqus comment counter:

<script type="text/javascript">
//<[CDATA[
(function() {
        links = document.getElementsByTagName('a');
        query = '?';
        for(var i = 0; i < links.length; i++) {
            if(links[i].href.indexOf('#disqus_thread') >= 0) {
                query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
            }
        }
        document.write('<script type="text/javascript" src="http://disqus.com/forums/FORUMNAME/get_num_replies.js' + query + '"></' + 'script>');
    }());
//]]>
</script>

Then I would need to edit the file post.view commenting out the line:

$macros.CommentUrl($post, "%{anchor='comments', class='comments'}")

Then commenting out the comment code set up for Graffiti from:

#foreach($comment in $comments)

...

#end

Replacing instead with the Disqus code (which you receive after signing up):

<div id="disqus_thread"></div>

<script type="text/javascript" src="http://disqus.com/forums/FORUMNAME/embed.js"></script>

<noscript>

<a href="http://FORUMNAME.disqus.com/?url=ref">View the forum thread.</a>

</noscript>

It's as simple as signing up over at http://www.disqus.com/

I'm still testing it all out, but I thought it might be interesting to use it, so there's some pointers!

Similar Posts

  1. Adding Disqus to Graffiti CMS (Take 2)
  2. Technorati Trackbacks and Graffiti CMS
  3. Identicons and Gravatars in Community Server thanks to CarKnee

Post a comment

Options:

Size

Colors