John’s Adventures

A Weblog Template With Comments

A screenshot of the template in actionI used to use CityDesk to manage my blog and I wrote code to handle comments for each article. So I thought I’d share the code to demonstrate how I did it.

The template I’ve created for this site is based upon the basic one I describe here, so familiarise yourself with that article first. And don’t be a Smart Alec and download the template and preview expecting it to work. It won’t! You just need to spent a couple of minutes reading this article, if you please…

Prerequisites

If you want to use my comments system on your own CityDesk site then you’ll need to have a couple of things. You’ll need to be able to run PHP scripts (check with your ISP) and also have the mySQL database installed on your server (again, check with your ISP). One thing to note is that if you want to test it you’ll need these installed on your own PC. You’ll no longer be able to use the preview option in CityDesk to see your site (as my scripts are .php and need to be run on a web server). I’m not going to explain how to install PHP and mySQL on a windows PC, but you should check out their websites (I’ve linked to them above) and follow their instructions. I found it to be pretty straightforward on my copy of Windows XP Professional though for what’s it’s worth.

The First Step

The first thing to do is download my CityDesk template:

Next, open it up and check out the variables (click View > Variables). You need to ask your ISP for the following values, although I’ve given a hint to what they probably are:

  • UserName - this is the mySQL user name that has access to the database.
  • DatabaseName - the name of the actual database.
  • Password - the mySQL user’s password.
  • HostName - normally ‘localhost’ but your ISP may have other ideas.

Now that you’ve got that sorted you’ll need to set up a publish location - I’m afraid that the site won’t work if you hit the ‘Preview’ button as I mentioned above. Check out the CityDesk documentation to figure out how to do that (it explains it better than I ever could).

Create The Database Tables

Now you need to create the tables in your mySQL database. If your site has uploaded correctly and you uploaded to ‘www.mysite.com’, then browse to ‘www.mysite.com/createtables.php’. If all goes well and you’ve correctly configured the three variables I mentioned above, then all you should see is the message ‘Done!’. If there is a failure message or nothing at all, then I’d advise you to talk to your ISP. If they’re no help, then drop me a line.

All the script does is create the tables that the comments system uses. One, ‘ArticleIndex’ maintains how many comments each article has and the other, ‘ArticleComments’ holds the actual comments. Your mySQL admin tool should let you browse the fields, although they’re not very interesting.

Once the tables have been created, just browse to ‘www.mysite.com’ (well, whatever your site is) and the site should work perfectly. If it doesn’t for any reason then drop me a line, because it works perfectly when I publish it to any location!

Using The Comments

Note that at the bottom of each article is the comments link and the count of how many comments there are in brackets, which should all be zero at first (unless it’s all gone wrong). You can now post comments in just the same way you can on most blogs.

Epilogue

If you’re not the techy type then you’ll notice that there’s some fairly complex stuff going on and you’ll probably not want to get too involved with how it all works. But don’t be scared! If you are the techy type and you notice any bugs or have any suggestions then don’t keep them to yourself.

Feel free to use the template as you see fit and if you use my comment code then all I ask is you let me know where your site is so I can take a look. Enjoy!

8 Comments on “A Weblog Template With Comments”

Stupid Question: To get preview to work ok on my PC (XP Pro), do I need to install Apache too and/or have IIS running?

Put another way, what webserver do you have installed together with MySQL and PHP?

Thanks for taking the time to write this up and make it available!

I use IIS along with MySQL and PHP on my windows box, I don’t use Apache. If you download PHP and MySQL from the links in the article and follow the instructions you shouldn’t have any problems getting it to work (famous last words). Drop me a line if you get stuck.

Hi John,
Love your template and used it directly on my site. It worked. I’ve just two questions:
- is it hard to give it a bad-word-filter?
- is it hard to add the functionality that the webmaster is mailed each time there is a new comment. If possible with the content.

Let me explain my questions. I’ve got a website about Polar bears. Very popular. Kids use it to make projects and so on. But some kids use the comments-feature to express other meanings than questions or remarks about Polar Bears. They curse or use other language I don’t think is appropiate. It’s impossible for me to check each day all comments…
I’ll send you this comment als by mail…:)

Marcel - the mail thing is pretty easy (2 lines). In the unlikely event that John hasn’t got back to you, let me know. I use John’s comments stuff and have modified them to do a few things.

Oh, don’t worry Andy, it’s sorted! :-)

I haven’t tried the solution, but the article has me interested!

I’m always fascinated to see how lively the CityDesk community still is - despite Joel’s refusal to develop the software further :-)

Cheers, Colm (an Irishman living in Germany!)

P.S. Now I’m disappointed - I wanted to check the spam catcher and I got an error message from WordPress. A quick look at the source of this page, shows that it’s not a CityDesk page :-(

Sorry, it’s obviously too early Sunday morning. It says very clearly at the top of the page “I used to use ….”

Yeah, a couple of years ago I switched to Movable Type and recently Wordpress. Web-based CMS software really has come along and is now a much better choice in my opinion than CityDesk since you can edit it from anywhere. However, I still use CityDesk to create Windows help files for software I write - frankly there’s no better tool for it that I’ve come across!

It’s a shame Joel didn’t keep on developing CityDesk but since FogBugz is such an amazing success and CityDesk only moderate I completely understand why he’s put his resources elsewhere. I’m sure if he’d open source it or something there would be people (like myself) keen to develop it further but I guess some revenue still trickles in for it so it’s not worth his while doing it.

Leave a Comment