Thursday, May 13, 2004

New Feature

I've just hacked together some new comment code to work with Blogger's new commenting system so you can see erm.. how many new comments there are on a post. At the minute it returns a pretty plain looking new comment bit but it's easy enough to put a flashing graphic in again.

It could be a bit ropy as it's my first time doing anything with cookies. I used Bill Dortch's public domain code for reading/writing the cookies and a few lines of my code for comparing your stored comment count with the current comment count and displaying something if anything is new.

At the minute every comment count is stored in it's own cookie rather than all values stored in 1 big Newlinks cookie and I haven't set a cookie expiry date (naughty) but I'll do those bits next. I figured get something up at least for now and worry about the hackiness later. It won't blow your PC up. Probably.

If anyone reads this and wants the code on your own site feel free to use it - Disclaimer: at your own risk. Please let us know if you do though. Once I've got code I'm totally happy with I'll put it somewhere for download with some install info.

8 comments:

mmChronic said...

Bugger - it's not persistent between sessions i.e if you close the browser, open a new one and come back teh counts are reset. I suspect that may have something to do with no expiry date but I'm not sure. As I say tthis is my 1st play with cookies.

It works fine if you keep using the same browser though i.e. hit front page, hit comments link, hit back to come to front page etc etc.

I''m looking at the persistence shizzle now...

ILuvNUFC said...

I thought the last "new comment" flashy thingy was pretty unreliable.Good luck :)

mmChronic said...

I think I've sorted the persistence problem. It was just a case of setting the expiry date which I set to 28 days.

Next stage is to get them all in 1 cookie.

bungers said...

Nice work. Let's sell the code. £50 sound about right? That'll sort our trip to Amsterdam out if we sell enough of them! ;)

Bungers
Commercial Manager.

mmChronic said...

Yeah - good idea. We'll have to do that more often - let me code my nads off for a few hours, then treat you lot to a drug & whore filled binge in Asmterdam with the proceeds. ;)

bungers said...

I like your way of thinking. I'll charge £60, and you can have a cabin with a window.

mmChronic said...

Yay! I'll sign up for that then! :)

ILuvNUFC said...

Me too!