Movable Type コメントにナンバーをつける

このサイトの人気の記事には結構な数のコメントがついている。ありがとうございます。コメント同士でのやりとりも見受けられるので、分かりやすいようコメントにナンバーを割り当ててみた。以下のタグでコメントナンバーを表示できる。

<mt:CommentOrderNumber />

表示場所は、コメントの日付の横にしてみた。具体的には、テンプレートの「コメント詳細」を以下のようにした。

<article id="comment-<$mt:CommentID$>" class="comment<mt:IfCommentParent> comment-reply</mt:IfCommentParent><mt:IfCommenterIsEntryAuthor> entry-author-comment</mt:IfCommenterIsEntryAuthor>" itemprop="comment" itemscope itemtype="http://schema.org/UserComments">
  <header>
    <h3><mt:IfCommentParent><span class="vcard author"><$mt:CommentAuthorLink$></span>から<a href="<mt:CommentParent><$mt:CommentLink$></mt:CommentParent>"><mt:CommentParent><$mt:CommentAuthor$></mt:CommentParent></a>への返信<mt:Else><$mt:CommentAuthorLink$></mt:IfCommentParent></h3>
    <a href="<$mt:CommentLink$>"><time datetime="<$mt:CommentDate format_name="iso8601"$>"><$mt:CommentDate$></time></a>
 [ <mt:CommentOrderNumber /> ]
  </header>
  <div class="comment-content" itemprop="commentText">
    <$mt:CommentBody$>
  </div>
<mt:IfCommentsAccepted>
  <div class="reply">
    <$mt:CommentReplyToLink$>
  </div>
</mt:IfCommentsAccepted>
</article>

以上で、すべてを再構築。これで各コメントにナンバーが振られる。コメントを降順に並べる場合はひと工夫必要らしいので、その場合は以下の小粋空間さんの記事を参照ください。

参考
コメント番号を降順で表示する (小粋空間)