Blogger Hacks, Categories, Tips & Tricks

Saturday, May 20, 2006
Grammatically Correct Comment Count?
A reader e-mails to ask how to hack the blogger comments code to make the post count grammatically correct... Comments (0), Comment (1), Comments (2), that sort of deal. Now, I'm pretty sure I've seen this somewhere before, but I can't recall where, which is why I'm opening the floor & hoping you'll remind me!

Filed in:
Posted at 11:49 AM by John.
6 Comments:
<    >
Blogger Aditya said...
There there! This just needs a4 lines of javascript! :P Put this where the 'Comment ()' is supposed to be written:

<script>

var number=<$BlogItemCommentCount$>;

if(number==1){
document.write('<a href=\"<$<$BlogItemPermalinkURL$>$>#comments\">Comment \(1\)</a>'); }

else{
document.write('<a href=\"<$<$BlogItemPermalinkURL$>$>#comments\">Comments ("+number+")</a>');
}
</script>


Should do the trick?

<    >
Hi, here is what I used:

<script type="text/javascript">var a = <$BlogItemCommentCount$>;
if(a == 0) {document.write('No comment');}else if(a == 1){document.write('1 comment');}else {document.write(a+' comments');}</script></a>


peace...
annie

<    >
Blogger Johan Sundström said...
Haven't we all written articles about that sort of thing, once upon a time? :-)

<    >
Blogger nell said...
thanks!

<    >
Blogger Gaby de Wilde said...
lol, I read all of those posts to.

In my post I suggest doing it like this:

-- css --

1com: {display:none; }

-- text in link --

commment<span class="<$BlogItemCommentCount$>com" >s</span>

The hardest part was finding a logical css class name for it. I've tried 1s and 1ass but it didn't look right. And 1grammarnatzi is to long.

I know it isn't as big as your scripts and it's only css1 but it works. The sad part is that the missing (s) makes people think about other things as posting the comment. And of course the page gets bloated from it. lol

<    >
Blogger Gaby de Wilde said...
It always makes me feel like an idiot talking about comments. Each time I write a script I have to post them myself.Comments are soooooo 1980. What am I doing here anyway? Was it a trick question?

Maybe you can repost some things from my blog. I did make the scripts to be used. Doesn't look like it's going to happen.lol

I'm looking for new ideas to make, have any ideas? Is there something left that wordpress can do but blogger cant?


eXTReMe Tracker