remotedotcomments

Want to use dotcomments in your blog, but your host doesn't support PHP? Phil Ulrich figured out how to host dotcomments on a separate free host that does support PHP, but now he has moved on to another comment system, then on to another host and domain name, and back to dotcomments, and his tutorial has gone missing along the way, so this is my modified version of it.

Find a PHP host

The first step is the hardest: you need to find a free host that supports PHP, isn't down most of the time, and preferably has FTP access and no ads (especially no popups, which tend to ruin the comment count). At the moment, that narrows it down to barrysworld, and sometime again, digitalrice. Sign up for an account with either one (or both, if you can, so you can switch back and forth), and once your account is activated, connect with your ftp program, create a directory named comments and chmod the directory to 777 (set Read, Write, and Execute permission for Owner, Group, and World). If you want to put comments.php in a subdirectory in your free host account, that's fine, just create the comments directory as a subdirectory of the directory where you plan to put comments.php.

Edit comments.php

Next (or while you wait for your account to be activated), download remotedotcomments.zip, my lightly modified version of dotcomments, and unzip it. Open comments.php in your favorite text editor. Edit the variables at the top as instructed in the dotcomments readme (the only one you absolutely have to edit is $comments_path).

Upload the files

Upload comments.php, commentcount.php, and dcbanner.gif to your free PHP host. Note that they do not go in the comments directory, but rather one level up: comments should be empty until it starts to fill with comment files. While you are at it, upload some sort of an index.html, so that it doesn't look like you are just abusing their generosity in supporting PHP.

Edit your template

Now, to edit your Blogger template. Somewhere between the <head> and </head> tags paste the following, changing www.mydomain.com to the address for your free PHP site:

<script type="text/javascript" src="http://www.mydomain.com/commentcount.php" defer="defer"></script>
<script type="text/javascript">
function viewComments(n) {
commentWindow=window.open('http://www.mydomain.com/comments.php?' + n, 'comments' + n, 'directories=0,height=480,location=0,resizable=1,scrollbars=1,toolbar=0,width=515');
}
function countcomments(){
 if (document.childNodes){
  if(typeof(commentID) != "undefined"){
   for (i=0;i<commentID.length;i++){
    oSpan = document.getElementById(commentID[i]);
    if(oSpan){
     oSpanText = oSpan.firstChild;
     while(oSpanText.nodeType != "3"){
      if(oSpanText.hasChildNodes)
       oSpanText = oSpanText.firstChild;
      else
       return false;
      }
     oSpanText.nodeValue = commentCount[i];
     }
    }
   }
  }
 }
</script>

In your <body> tag, include onload="countcomments()" so that you have something like:

<body link="#336699" vlink="#003366" alink="red" onload="countcomments()">

In the spot in your byline where you want the comment link to appear, include:

<a href="javascript:viewComments(<$BlogItemNumber$>)"><span id="comment<$BlogItemNumber$>">comment</span></a>

Finally, if you want to include the dotcomments banner, use:

<a href="http://www.foreword.com/dotcomments.php"><img src="http://www.mydomain.com/dcbanner.gif" width="88" height="31" border="0" alt="Comments by dotcomments"></a>

Again, replace www.mydomain.com with the address of your PHP site.

Publish and test

Publish your blog, and check it out. You should see links below each post that say "comment". Click one and make a test comment, and then reload your blog to see if the comment link changes to "1 comment" (note that comment counting only works if you are using a DOM compliant browser: IE 5+, Netscape 6, sometime in the future Opera). Once it's working, republish your archives if you want comments there as well.




August 5, 2001
Moved my main "how to" to a permanent post at the top of the page. Use any older instructions below at your own risk...