August 02, 2008 ~ Blogger Tutorials

Benefits

Numeration is the very best way of organizing our comments, as it allows to identify each comment; becoming a great feature for giveaway posts. It also allows you to get the permalink (permanent link) of each comment for future reference, and on top of everything, it is indispensable for design purposes.

Limitations

If our comments are paginated, the counter will reset in each comment page. Comments are automatically paginated if they surpass the 200.

Installation

We first need to install the script. To do this, from our Template Editor, in our Blogger Dashboard, after expanding the widget templates, we must add what is highlighted here below, in the following code:

<b:includable id='comments' var='post'>

........

<dl id='comments-block'>

<script type='text/javascript'>var CommentsCounter=0;</script>

<b:loop values='data:post.comments' var='comment'>

<dt class='comment-author' expr:id='"comment-" + data:comment.id'>
<a expr:name='"comment-" + data:comment.id'/>
<b:if cond='data:comment.authorUrl'>

<a expr:href='data:comment.authorUrl' rel='nofollow'>
<data:comment.author/>
</a>
<b:else/>
<data:comment.author/>
</b:if>
<data:commentPostedByMsg/>

<span class='numberingcomments'>

<a expr:href='data:comment.url' title='Comment Link'>
<script type='text/javascript'>
CommentsCounter=CommentsCounter+1;
document.write(CommentsCounter)
</script>
</a>
</span>

</dt>

<dd class='comment-body' style='clear: both;'>

.......
</dd>

</b:loop>
</dl>

Customization

In order to style the numbers, we need to copy and customize the following code, right before ]]</b:skin>:

span.numberingcomments {
float: right;
font-size: 20px;
}

Of course, many more CSS properties can be added.

Styling even and odd comments

The original hack proposed by JMiur from Vagabundia includes the option of styling pair et impair (even and odd) comments.

Demo

You can take a look at the result right here.

Reference

Vagabundia

More in this category:

  • I'm interested in help for the new templates. I use a customized one will the updated code work for that? I hope.
  • I hope so, too. I'm sorry I haven't yet been able to look into this request. I will soon, hopefully. When I do, I'll contact everybody and update this post of course.
  • emmyscloset
    I just tried and can't get it to work :( I really need this, as I have giveaways too! I see you've written that layouts have changed and I JUST started my blog a week ago. Do you think this could be the reason? If you figure something out and could email me that would be GREAT!! Thanks so much!!
  • I'll make sure I e-mail everyone who has requested help once I update this tutorial. Thanks for your patience! :)
  • It is a bit confusing, probably as mentioned due to new blogger code.

    But it worked fine. :-)

    Thanks a lot!
  • I'm glad it worked in the end!

    (I'm sorry I had to edit your comment; Disqus wouldn't show the code.)
  • Hi,

    I have been trying my best to get this on, because I need it so, so much as I have giveaways. :-)))
    I get stuck at the 3rd code; I tried and so did a pal who knows about this, but it just doesn't happen.

    The last time, I got this:

    "Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
    XML error message: White spaces are required between publicId and systemId."

    Help!
    I did do it extra carefully, but it won't let any changes happen.
  • SuMMer,

    This tutorial is based on Blogger's previous comment system. It is possible your template has the new one (which includes the avatars displayed at the left of each comment): because of this, the template code must have changed. I haven't had time to update this tutorial to match the new code. When/if I do, I'll send you an e-mail.

    I'm sorry I can't be more helpful.

    Best,

    F.
  • I recently switched to a new blogger layout, but when I did so I lost my ability to number comments. Can you see where I went wrong?

    http://mommys-minute.blogspot.com
  • Hey Sarah,

    New Blogger layouts have a different comment structure. I haven't had time to check that and update this tutorial. If/when I do, I'll contact you via e-mail. Thanks! (And sorry for any incovenience.)
  • nicole
    It didn't work for me. :(

    http://vertcanada.blogspot.com

    I don't know what I did wrong!!
  • Nicole, neither do I, sorry. Try doing it again but this time more carefully. Blogger's comment layout has gone through some changes, so perhaps that's it. I haven't checked or updated this tutorial ever since it was written. I'm sorry.
  • keylime
    Yay!!! I have been trying to get my comments numbered with NO luck! But I just tried your tutorial and now I have numbered comments!! Thanks!
  • :D Perfect!
  • sarsy
    Thanks for nice tips it works well for me.

    Kindly check for your record

    www.creativelayer.blogspot.com

    Thanks
  • That's great!
blog comments powered by Disqus