Yesterday, in addition to making my PHP workaround, I also wrote a Movable Type plugin I call “True Comment Number.” If you look at an entry on this blog that has comments, you’ll notice that I number them, starting with “1” for the first comment, and going up from there. This numbering was not working properly with paginated comments, so that’s why I wrote True Comment Number.
Anyone who wants my plugin may download TrueCommentNumber.zip and use it.
What is it?
The True Comment Number plugin adds a new Template Tag, <$mt:TrueCommentNumber$> to Movable Type. This tag can replace the <$mt:CommentOrderNumber$> tag in the context of comment pagination.
<$mt:CommentOrderNumber$> is a good tag for numbering your comments in a list. It starts with “1” and keeps adding 1 for each comment. But the problem with <$mt:CommentOrderNumber$> is, it starts with “1” even when it should be starting from a higher number. Say you clicked on the “newer comments” link to see comments 51 - 100, then you would think the first comment would be numbered “51.” But <$mt:CommentOrderNumber$> would number it “1,” because it does not take the offset (i.e., the 50 comments being skipped) into consideration.
That’s where <$mt:TrueCommentNumber$> comes in. If you are looking at comments 51 - 100, it will start at “51.” If you are looking at comments 2801-3000, it will start at “2801.” It will always give you the true order number of the comment.
What does it do, exactly?
The <$mt:TrueCommentNumber$> tag works almost exactly like the existing <$mt:CommentOrderNumber$> tag. In fact, for regular publishing, it will return exactly whatever <$mt:CommentOrderNumber$> would have returned. No difference at all. Except that if it is in the context of a batch of comments that have been retrieved by an an AJAX script, it will add the “offset” value to the comment number.
How do you use it?
You can use it in your “Comment Detail” template if you want comments numbered. For a very stripped-down example…
<div id="comment-<$mt:CommentID$>" class="comment">
<span class="comment-number">
#<$mt:TrueCommentNumber$>:
</span>
<div class="comment-content">
<$mt:CommentBody$>
</div>
</div>
Does it work?
It works for me, on Movable Type version 5. I have not tested it on any other versions, and make no warranties of any kind. If you want to modify it in any way, go right ahead.
Have fun!
11:45 PM
You are so wonderful.
12:42 AM
Hey darlin, me again. Tell your students they have to make this for the next quiz: http://www.youtube.com/watch?v=-0Xa4bHcJu8
8:08 AM
Great way to expand to reach a new audience. Go Twitter!
I hope all goes well for you :)