My Photo
Name:
Location: Madison, Wisconsin, United States

My friends are doing it, so why not conform? I will not promise the sort of blog dedication I seem to be seeing from them, however, so don't expect much. Just a way for me to "fit in." No, strike that - a way for me to organize some thoughts. (There, that sounds better...)

Oh, by the way...I just wanted to state that the opinions expressed in these posts are my own. Not my family's, not my friend's, not my workplace's, and certainly not yours. (Well, I should clarify that by saying any similarity to the opinions of the people or groups detailed above is purely coincidental.) Do ya' get it? Don't come down on anyone else for the things I say! (Sheesh!)

20060918

HOWTO: Adjust Plurality of Blogger Comment Count

...or, 'If I've Told You Once, I've Told You A Thousand Time'


I've often been bothered by the fact that my Blogger template doesn't distinguish between a single comment and zero or multiple comments. Well last night, I decided to do something about it. I'm by no means a JavaScript expert, but this was trivial.

Now, if I have a single comment, it will reflect "1 comment." If I have 0 comments, "0 comments," or 2+ comments, "2 comments."

To make the change yourself, back up your Blogger template, then search it for any entries like so: "<$BlogItemCommentCount$> comments", (without the quotes). Replace the "s" in "comments" with the following code, (on one line, for simplicity, and immediately after the word "comment"!):

<script type="text/javascript">document.write((<$BlogItemCommentCount$> != 1)?'s':'');</script>

Save Template Changes, Republish and you'll be good to go.

The template will now spit out "# comment" unconditionally. It will then look at the number of comments. If it is 1, it does nothing, otherwise, it appends an "s", making it plural.

0 Comments:

Post a Comment

« Home