Threaded Comments - Hiranyaloka/Documentation GitHub Wiki

This page contains examples of Comment Threading in Movable Type and is complimentary to this the Comment Threading documentation:

http://www.movabletype.org/documentation/mt42/threading.html

Example Code for Hierarchically Threaded comments in MT 4.2

This code first sets a variable to contain the comment detail template, then uses includes the template for top-level comments and then child-comments recursively.

<mt:SetVarTemplate name="comment_detail_template">
    <div id="comment-<$MTCommentID$>" class="comment<mt:IfCommentParent> comment-reply</mt:ifcommentparent>">
        <div class="inner">
            <div class="comment-header">
                <div class="asset-meta">
                    <span class="byline">
                        <$MTCommentAuthorIdentity$>
    <mt:IfCommentParent>
                        <span class="vcard author"><$MTCommentAuthorLink$></span> replied to <a href="<mt:CommentParent><$mt:CommentLink$></mt:commentparent>">comment from <mt:CommentParent><$MTCommentAuthor$></mt:commentparent></a>
    <mt:else>
                        <span class="vcard author"><$MTCommentAuthorLink$></span>
    </mt:ifcommentparent>
                        | <a href="<$mt:CommentLink$>"><abbr class="published" title="<$MTCommentDate format_name="iso8601"$>"><$MTCommentDate$></abbr></a>
    <MTIfCommentsAccepted>
                        | <$MTCommentReplyToLink$>
    </mtifcommentsaccepted>
                    </span>
                </div>
            </div>
            <div class="comment-content">
                <$MTCommentBody$>
            </div>
        </div>
    </div>
</mt:setvartemplate>


<MTComments>
    <MTCommentsHeader>
<h2 class="comments-header"><$MTEntryCommentCount singular="1 Comment" plural="# Comments" none="No Comments"$></h2>
<div class="comments-content">
    </mtcommentsheader>
    <mt:IfCommentParent> 
        <mt:Else> 
            <$mt:var name="comment_detail_template"$>
        <mt:CommentReplies> 
            <mt:CommentsHeader>
            <div style="margin-left: 20px;">
            </mt:commentsheader>
            <$mt:var name="comment_detail_template"$>
            <$mt:CommentRepliesRecurse$>     
            <mt:CommentsFooter>
            </div>
            </mt:commentsfooter>
        </mt:commentreplies>
    </mt:ifcommentparent>
    <MTCommentsFooter>
</div>
    </mtcommentsfooter>
</mtcomments>

Example Code for Hierarchically Threaded and Nested comments in MT 4.2

Parent comments are output in UL. Each comment is placed in an LI. If a comment has replies, the replies are placed in a new UL included just be fore the closing LI for the parent comment.

This example is from the comment threading implementation in the Forums Template set as of MT 4.2. Note, comments are called "Replies" in context of the Forums Template set.

<MTIfCommentsActive>
<div id="comments" class="comments">
    <MTComments>
        <MTCommentsHeader>
    <div class="comments-header">
        <h2><$MTEntryCommentCount singular="1 Reply" plural="# Replies" none="No Replies"$></h2>
    <MTIfCommentsAccepted>
        <span class="separator">|</span>
        <a href="#comments-open">Add a Reply</a>
    </mtifcommentsaccepted>
    </div>
    <ul class="comments-content">
        </mtcommentsheader>
        <mt:IfCommentParent>
            <mt:Else>
        <li>
            <$mt:Include module="Comment Detail"$>
            <mt:CommentReplies>
                <mt:CommentsHeader>
            <ul>
                </mt:commentsheader>
                <li>
                    <$mt:Include module="Comment Detail"$>
                    <$mt:CommentRepliesRecurse$>
                </li>
                <mt:CommentsFooter>
            </ul>
                </mt:commentsfooter>
            </mt:commentreplies>
        </li>
        </mt:ifcommentparent>
        <MTCommentsFooter>
    </ul>
        </mtcommentsfooter>
    </mtcomments>
    <$MTInclude module="Comment Form"$>
</div>
</mtifcommentsactive>
⚠️ **GitHub.com Fallback** ⚠️