JS-Kit Recent Comments PHP Script

×

This post was originally published in 2009
It may contain stale & outdated information. Or it may have grown more awesome with age, like the author.

Jealous of people able to display their blog’s recent comments in the sidebar, I wrote this little script.

It reads recent posts from your site’s comment rss feed and prints n comments out in a nicely formatted div. Using it is as simple as changing one line, uploading the file, and pasting some code wherever you want the recent comments to be displayed.

I tried to make a javascript version, but I the cross-domain AJAX issue thwarted my attempts. Instead I wrote it in PHP – if you don’t have PHP enabled on your hosting then you won’t be able to use this script, sorry!

To use the script, first download it.

Open the file in a text editor. Change the ‘$commentsRSS’ value to your JS-Kit Comments RSS URL. This is the line:

4
$commentsRSS = 'http://rss.pagesofinterest.net/';	//change this to your comments rss feed

To find your RSS URL, look here: Customizing JS-Kit Comments. Scroll until you see “Setting up the RSS”.

Once you’ve changed that variable, rename the file to “recent-comments.php”, and upload it to your server.

Take note of where you uploaded it to.

Paste

< ?php include('PATH_TO/recent-comments.php') ?>

wherever you want your recent comments to be displayed.
Change “PATH_TO” to the path to the file, e.g. “http://pagesofinterest.net/code/download/recent-comments.php”. Remove the whitespace between < and ?.

Save, then load the page in your browser. You should see your recent comments displayed wherever you pasted the code.

If you see a strange error message instead, try pasting the contents of the recent-comments.phps file wherever you want the recent comments to be displayed, instead of the above “include” statement.

Any problems, leave a comment and I’ll try to help.

To learn more JS-Kit tricks, read the following posts:

JS-Kit Comments + Greybox on Any Page
Fancy Footer
JS-Kit Comments for Each Blog Entry
JS-Kit Comments: Correct Usage of the ‘Permalink’ and ‘Path’ Attributes
Styling JS-Kit Comments
JS-Kit Comments: Correct Usage of the ‘Permalink’ and ‘Path’ Attributes

Comments (6) | Trackback