Thursday, 22 June 2006

Correct comment count in blogger

My friend over at Beks and Ro, who is as picky as I am about her blog template, wanted to know how I got my comments to be 'correct'. Meaning if there are no comments it will say "0 comments" and if there is one comment it will say "1 comment" or if there are eight comments it will say "8 comments". Here is the code I inserted between the <Blogger> </Blogger> elements.
<MainOrArchivePage><BlogItemCommentsEnabled>
<a class="comment-link" href="<$BlogItemCommentCreate$>"
<$BlogItemCommentFormOnclick$>><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>
</BlogItemCommentsEnabled><BlogItemBacklinksEnabled>
<a class="comment-link" href="<$BlogItemPermalinkUrl$>#links">links</a>
</BlogItemBacklinksEnabled></MainOrArchivePage>


post signature

No comments:

Post a Comment