Adding Disqus to Graffiti CMS (Take 2)

written by Andrew Tobin on Friday, December 07 2007

Edit: I completely overlooked the fact that disabling the Grafitti CMS comment system would disable the new comment box in the theme I was using, I am editing this entry to reflect that you do not need to make some of the changes I first mentioned! - Keep Your Current Comments and Migrate to Disqus

So after some advice from @ScottW I've made the Disqus Engine part of a Graffiti Chalk plug-in!

Basically you will still need to alter some code in your themes, but it's a little easier:

Step 1:  Add the plug-in file to your ~/bin/ directory

http://grrargh.com/files/media/file/AndrewTobin.Graffiti.DisqusPlugin.dll

Step 2: In the Site Options of Graffiti under the Comments section, turn Comments off!

In the current themes this will stop the "Add new comment" box appearing, but will keep your existing comments.

Step 3: Alter your post.view theme file in your ~/files/themes/<THEME> directory

What you want to do is comment out this line:

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

It's not really required anyway, to know how many comments you have on the blog post page that you're on - Disqus will show the number anyway in it's section.

Then add the Disqus Comment Box via Chalk below the existing Graffiti comment code (It will keep old comments above the Disqus box, and Disqus comments below the box):

$disqus.CommentBox("<DISQUSFORUM>")

Step 4: Alter your index.view theme file in your ~/files/themes/<THEME> directory

Comment out the Graffiti comments code:

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

Add directly below that, the Disqus Comment Count via Chalk code:

$disqus.CommentsCount("<DISQUSFORUM>", $post)

And then after the #nodata ... #end sections of the posts add the code that fetches all the comments counts from Disqus.

$disqus.FetchCounts("<DISQUSFORUM>")

The end result is the code will look something like this:

<!-- $macros.CommentUrl($post, "%{anchor='comments', class='comments'}") -->
        $disqus.CommentsCount("<DISQUSFORUM>", $post)
    </p>
</div>

#nodata
<div class="entry">
    Sorry, there are no posts matching your request.
</div>

#end

$disqus.FetchCounts("<DISQUSFORUM>")

 

With this method you only need a couple of short additions to your theme, rather than some javascript inline.

If you have any questions or comments, please feel free to leave them and try out Disqus for yourself!

*<DISQUSFORUM> obviously refers to the name you give your forum/comment system when you sign up!

Similar Posts

  1. Technorati Trackbacks and Graffiti CMS
  2. Identicons and Gravatars in Community Server thanks to CarKnee
  3. Integrating Disqus into Graffiti CMS

Comments

  • jer979 on on 5.21.2008 at 12:26 PM

    jer979 avatar

    cool work here. Only thing is, as soon as I add your dll to my bin file, my site breaks, as in 404 error.

    It's strange. I'm on 1.0.1. Any ideas what I may be doing wrong here?

    Thanks!

Post a comment

Options:

Size

Colors