Comment Integration

Site Map

What is Comment Integration?

In recent talks and seminars I have been emphasizing the idea of comment integration, that is, the idea of placing content and comments about that content on the same page.

In many online courses - and on many websites - the discussions are located on a discussion board far away from the content pages.

This makes discussion harder to use (and therefore less used). When people have to click about to find a place to enter their opinion, they usually don't.

While I was in Australia recently, I was challenged to put the recommendations into practice. It seems there isn't really an easy way to integrate content and comments.

So I wrote a couple of short perl scripts, along with some HTML and Javascript code, which will allow you to quickly and easily embed comments in your content pages.

Installing the Program

First, here are the scripts (use the right-click button on your mose to save them to your hard drive and click here to get them in a zipped archive):

  • comment.cgi - main comment script
  • initcomment.cgi - initializes a new comment stream
  • sample.htm - HTML page with sample form and Javascript
  • thankyou.htm - Content of Thank You page

To make these work on your website, upload the scripts to a CGI directory and the web page to an HTML directory. I set mine up as follows:

   ---------- cgi-bin --- comments -------- comment.cgi
         |                    |------------ initcomment.cgi
         |                    |------------ thankyou.htm
         |                    |------------ comments/ (data goes here)
         |--- content --- sample.htm

If you are using a unix or linux system, set the permissions so the CGI scripts are executive (i.e., chmod 755). Make sure also that the directory where your web page is located is writable (chmod 766) because we will be outputting files there. Your data directory cgi-bin/comments/comments/ should also be writable (and prefarable, protected by a .htaccess file).

Now you need to make some small changes to the CGI scripts so they will work on your own system.

If you use unix or linux, the first line will have to read: #!/usr/bin/perl or whatever is appropriate to your system. Check with your webmaster if you don't know what this line should be.

If you are using NT, you may have to change two lines which indicate where the output files are being written. These lines are located in comment.cgi and look like this:

$filename = "comments/" . $topic . ".dat";
$jsfile = "../comments/" . $topic . ".js";
The full directory name would look like this:
$filename = "D:\www\iis\htdocs\cgi-bin/comments/" . $topic . ".dat";
$jsfile = "D:\www\iis\htdocs\content/comments/" . $topic . ".js";
(don't worry about the forward and backward slashes; it all works in perl. Really.)

In initcomment.cgi, you may need to specify an absolute directory in this line as well:

$jsfile = "../comments/" . $topic . ".js";

Creating a Comment Page

Once you have your scripts loaded and you have made any changes you need, you are ready to create your first comment page. To begin, you need to initialize the comment. Using your web browser, run the initcomment script by typing it into the location line. Use this command to name your topic. For example, type:


Note: if you plan to use Netscape at all, ever, do not put a space in the topic name after topic=

Next, set up your web page. You need two things: a form, where readers can type their comments, and a Javascript command, which will place the comments onto the page.

You will need to change the URLs in this code to point to your own site. I've indicated that in green. You will also have to change the topic to match trhe one you just created. I have indicated that in red:


<form method="post" action="">
<input type="hidden" name="topic" value="demo">
<textarea rows=5 cols=40 name="comment"></textarea><br>
Your name: <input type="text" name="name" size=15> (Optional)<br>
Display comments? <input type="radio" name="display" value="yes" checked> Yes
<input type="radio" name="display" value="no" checked> No<br>
<input type="submit" value="Submit Comments"></form>

Print Out Comments

<script LANGUAGE="Javascript" SRC=""> </script>

Using the Comment Generator

Now you're ready to use your comment generator. Type a message into the box and press enter. You will be taken to a 'thank you' page with a link back to the original page. There, you may have to reload in order to view your new comment.

As the comment site owner, you have the option to delete any (or all) of the comments. Notice that each comment is numbered (the number is in the square brackets following the comment). To delete a comment, type:

Delete n Timmy
where n is the comment number you wish to delete (The word 'Timmy' is the password; you may want to change the password by editing the comment.cgi script).

Here are some more commands:

Delete 1-5 Timmy - deletes 1,2,3,4 and 5
Delete 1,5 Timmy - deletes 1 and 5
Delete 1,4-6 Timmy - deletes 1, 4, 5 and 6

Email Option

If you are using a unix or linux system, you can have the program send you an email message each time someone submits a comment.

To send email, first uncomment the send_note commpand by removing the # from the beginning of the line. The line should look like this:


Then enter your own email address where it says $to. Note: you must put a slash befor the ampersand character (i.e., type fred\, not

Finally, you may have to change the following line so that it points to Sendmail correctly:

$Mailprog = "/usr/sbin/sendmail";
Contact your system administrator if you don't know the address of Sendmail.

Your Comments

Your name: (Optional)
Display comments? Yes No