Tag Archives: disqus

Integrating Disqus and Roller Weblogger on blogs.sun.com

I’ve recently updated my site to use Disqus the blog comment hosting and conversation site.

Done this for two reasons:

  1. Firstly my usually frustration with any status quo means I want more functionality delivered yesterday, and although I’d started to have a look at the functionality I wanted and how I might add it as a Roller macro / velocity code I didn’t want to spend a huge amount of time coding it out (the functionality I specifically wanted was the separation of comments and trackbacks, as well as comment ‘threads’).
  2. Secondly to gain readership and comments from the sizeable blog comment audience that Disqus have built up (Disqus is estimated to be running on over 30,000+ servers).

I’ve already had a couple of comments from Disqus members, and I’ll have to see how it goes before I start heralding it as an unprecedented success, but I’m very pleased with the results (both aesthetic and functional).

Sadly the Disqus comment import function was initially provided for WordPress and Blogger, but apparently wasn’t fully functional; subsequently an update is due out soon that will hopefully include Roller Weblogger. See this Disqus forum entry, and it’s threads for more info: How do I import comments?

Given this was the case I wanted to make sure my blog supported my new Disqus commenting system, but would still show my old comments if there where any for an entry. Here are a few examples:

The code I developed, which has to be separated into two components (number of comments associated with a blog entry, and comment entry form and comment display), is below, but if you use or copy it please note that you need to replace the Disqus supplied JavaScript for my site with your Disqus comments hosted sites JavaScript code. ¨C18C

Combined Roller Weblogger and Disqus Number of Comments code

For comment numbers I’ve broken it down into displaying “n Comments” for Disqus on it’s own, whilst “x Comments (new, via Disqus) and y Comments (legacy, via Roller)” for comments hosted on both systems.

This replaces the code in the Roller Weblogger “_day” template which displays the number of comments per blog entry.

Don’t forget to replace occurrences of ‘eclectic’, my blog handle, with yours (just one, about the fifth line from the end).

## Number of Comments

<a href="$url.entry($entry.anchor)#disqus_thread">View Comments</a>

#set($commentCount = $entry.commentCount)
#if ($commentCount &gt; 0)
    (new, via <a href="https://web.archive.org/web/20090830081824/http://www.disqus.com/" target="_blank">Disqus</a>) and 
    #if ($commentCount == 1)
        <a href="$url.comments($entry.anchor)">$commentCount Comment</a> (old, via <a href="https://web.archive.org/web/20090830081824/http://rollerweblogger.org/" target="_blank">Roller</a>) 
    #else
        <a href="$url.comments($entry.anchor)">$commentCount Comments</a> (old, via <a href="https://web.archive.org/web/20090830081824/http://rollerweblogger.org/" target="_blank">Roller</a>) 
    #end
#end

<script type="text/javascript">
//<[CDATA[
(function() {
		var links = document.getElementsByTagName('a');
		var 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="https://web.archive.org/web/20090830081824/http://disqus.com/forums/eclectic/get_num_replies.js' + query + '"></' + 'script>');
	})();
//]]>
</script>

Combined Roller Weblogger and Disqus Comment entry and Comments display code

This basically displays the Disqus commenting system, along with any Disqus hosted comments, however if any ‘legacy’ Roller Weblogger hosted comments are found it displays those too.

It replaces the code in the Roller Weblogger “permalink” template which displays comments themselves (the same changes may need to be made to the “weblog” and “searchresults” templates too).

## Comments

<h2>Comments (new, via <a href="https://web.archive.org/web/20090830081824/http://www.disqus.com/" target="_blank">Disqus</a>)</h2>

<div id="disqus_thread"></div><script type="text/javascript" src="https://web.archive.org/web/20090830081824js_/http://disqus.com/forums/eclectic/embed.js"></script><noscript><a href="https://web.archive.org/web/20090830081824/http://eclectic.disqus.com/?url=ref">View the forum thread.</a></noscript><a href="https://web.archive.org/web/20090830081824/http://disqus.com/" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>

##showWeblogEntryComments($model.weblogEntry)
##showWeblogEntryCommentForm($model.weblogEntry)

<br></br>

#set($commentCount = $entry.commentCount)
#if ($commentCount &gt; 0)
    <h2>Comments (old, via <a href="https://web.archive.org/web/20090830081824/http://rollerweblogger.org/" target="_blank">Roller</a>)</h2>
    #showWeblogEntryComments($model.weblogEntry)
    <br></br>
#end

Additional benefits that I’ve picked up by implementing Disqus include:

  • Following commentators.
  • Having my, and my sites, comments followed.
  • Being able to easily ‘reblog’ my comments and make blog entries out of them (looking forward to trying this, although I haven’t yet).

Finally here’s my Disqus profile for you to have a look at: http://www.disqus.com/people/wayne_horkan/

Links for this article: