Comment threading is the ability for readers to respond to specific comments on a blog, web site or forum, and for other readers to more easily follow that conversation by seeing which comments are in response to others.
There are generally two types of threading one can deploy on their blog:
Chronological Threading
This is where comments are displayed strictly in chronological order with a simple note saying, "this comment is in response to So-and-so's comment".
Hierarchical Threading
This is where comments appear nested, meaning comments in response to other comments appear next to one another.
Installing Threaded Comments
Starting with Movable Type 4.15, Movable Type's default templates will have chronological threading support built in. Any new blog, web site or forum created using Movable Type will not need to modify their templates in order to take advantage of this feature.
Users upgrading to Movable Type 4.15 however will need to make slight modifications to their templates in order to create threaded comments on their site.
Setting up the Reply To links
The first step is to add the
<MTCommentReplyLink>template tag where you would like theReplylink to appear. This must be within an<MTComments>container tag. We recommend placing it in the comment posted byline:<p class="comment-footer"> Posted by <$MTCommentAuthorLink default_name="<MT_TRANS phrase="Anonymous">"$> <$MTCommentAuthorIdentity$> | <a href="#comment-<$MTCommentID$>"><$MTCommentDate$></a> | <MTCommentReplyLink> </p>By default,
MTCommentReplyLinkcreates a link with the textReply. However, this can be customized by giving the tag an optionaltextattribute like so, for example<MTCommentReplyLink text="Reply to this comment">.The next step is to use a new
<MTRepliedComment>container tag to show who the commenter is replying to. You can use any of theMTCommenttemplate tags you find in Movable Type within anMTRepliedCommentcontainer as well as<MTElse>which can be used as the "default" (i.e. if the comment is a new thread and not replying to someone else). Once again, this tag must be placed within an<MTComments>container tag and we recommend the posted byline:<p class="comment-footer"> <MTRepliedComment>Posted, in reply to <a href="#c<MTCommentID>"><MTCommentAuthor>'s comment</a>, by<MTElse>Posted by</MTElse></MTRepliedComment> <$MTCommentAuthorLink default_name="<MT_TRANS phrase="Anonymous">"$> <$MTCommentAuthorIdentity$> | <a href="#comment-<$MTCommentID$>"><$MTCommentDate$></a> | <MTCommentReplyLink> </p>So with the above example, if the comment was replying to someone else, the posted byline would read:
Posted, in reply to X's comment, by YWhereas if it were a new thread, it would simply read:
Posted by YThe final step is to add the
MTCommentReplyFieldtemplate tag within your comment form. We recommend it is added straight after the "remember me" checkbox:<p> <label for="comment-bake-cookie"><input type="checkbox" id="comment-bake-cookie" name="bakecookie" onclick="if (!this.checked) forgetMe(document.comments_form)" value="1" /> Remember personal info?</label> </p> <MTCommentReplyField>
Once these changes are made, make sure to rebuild the necessary files!
Chronological Comment Threading
Chronological Threads display comments sorted by the date they were posted. If a comment was posted in reply to another, this information is shown inline rather than indenting the entire comment (thus creating a hierarchy).
The following steps guide you through editing your templates to display chronological threads. These instructions have been tailored to match the default templates. If you have customized your comment templates, these are bound to be different so you will have to adapt the logic:
Open the
Comment Detailtemplate module and search for:<$MTCommentAuthorLink default_name="Anonymous" show_email="0"$> <MTIfNonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty> said:To change this to a chronological thread, we will need to first check if the comment is a reply (i.e. if it has a parent). If it does, replace
saidwith something more appropriate. Something like this works great:<!-- This displays the commenter's name and is the same as before --> <$MTCommentAuthorLink default_name="Anonymous" show_email="0"$> <MTIfNonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty> <!-- Check if the comment has a parent i.e. is it a reply? --> <MTIfCommentParent> <MTCommentParent> <!-- Set the context to the parent --> <a href="#comment-<MTCommentID>">replied to <MTCommentName>'s comment</a> </MTCommentParent> <MTElse> <!-- If this isn't a reply then --> said </MTIfCommentParent>Republish your templates. Your comments should now be in a chronological thread, for example:
Hierarchical Comment Threading
Hierarchical Threads are the more traditional way of displaying comment threads. Here, "top level" comments (i.e. those without replies) are sorted by date. For each comment, replies to it are listed underneath and indented slightly.
The following steps guide you through editing your templates to display hierarchical threads. These instructions have been tailored to match the default templates. If you have customized your comment templates, these are bound to be different so you will have to adapt the logic:
Open the
Commentstemplate module and search for this line:<$MTInclude module="Comment Detail"$>To change this into a hierarchical thread, we will need to look through the top level comments and for each top level comment, look through its replies (indenting each one as appropriate). Something like this works great:
<MTIfCommentParent><MTElse> <!-- This conditional checks to make sure that this comment isn't a reply --> <!-- Display the top level comment --> <$MTInclude module="Comment Detail"$> <MTCommentReplies> <!-- Here we loop through the replies and for each reply --> <!-- if it is the first of that "level/depth", indent it --> <MTCommentsHeader><div style="margin-left: 20px;"></MTCommentsHeader> <!-- Display the comment --> <MTInclude module="Comment Detail"> <!-- And loop through this container for replies of replies and so on --> <MTCommentRepliesRecurse> <!-- If this reply is the last of that "level/depth" close the div we opened to indent --> <MTCommentsFooter></div></MTCommentsFooter> </MTCommentReplies> </MTIfCommentParent>Republish your templates. Your comments should now be in a hierarchical thread, for example:
About this feature
This feature was the result of the gracious contribution of Simply Threaded by Arvind Satyanarayan. Thank you Arvind!
Submit a User Contributed Note
User contributed notes are a great way to share the knowledge you have gained in using Movable Type.
If you have a technical question or problem, please visit Movable Type Support.