Creating Hierarchical Threads

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. An example of hierarchical comment threads is shown in the screenshot below (from digg.com):

Hierarchical Threads from digg.com

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:

  1. Open the Comments template module and search for this line

    <$MTInclude module="Comment Detail"$>
    
  2. 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>
    
  3. Republish your templates. Your comments should now be in a hierarchical thread, for example:

    Hierarchical Threads in Movable Type

6 Comments

Rob Buckley said:
on Sep 25, 2007 10:33 PM | Reply

That only seems to work when you have single levels of reply. When you have replies to replies to comments the MTCommentsFooter section doesn't work. I'm having a think to see if I can come up with a solution...

Bethlet said:
on Oct 23, 2007 12:54 PM | Reply

Is there any way to set it up so people are emailed when someone replies to their comments? Is this something coming in a future release?

subbu said:
on Nov 12, 2007 1:20 AM | Reply

Thanks for a great plugin. At last, Movable Type has threaded hierarchical comments!

John Shannon said:
on Dec 19, 2007 11:12 AM | Reply

Indeed, many thanks.

Vee replied to Rob Buckley's comment:
on Jan 16, 2008 9:43 PM | Reply

Looks good to me and just what I want.

I'm concerned that there will be dozens of replies to replies to replies... Also, if the replies are long, how will that look? Only one way to find out, I guess.

Great work, Arvind. :)

bug? said:
on Mar 6, 2008 6:53 AM | Reply

i was testing this out (before using it commercially- we're definitely licensing it) and noticed that it doesn't check the checkbox for the reply in IE7 on XP.

moving the call to set the checked attribute after the call to appendChild works in both IE7 and FF, though. couldn't figure out a damn thing to get it working in IE6. haven't tried safari yet.

anyway, great work.

About

This is part of the official user manual for Simply Threaded, a plugin for Movable Type by Arvind Satyanarayan.

More Information »

Screenshots

Click a screenshot to browse through the gallery or the arrows to flip through them

←→

I Heart Melody