Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Comment hierarchy/threads/tree

edited August 2009 in Vanilla 2.0 - 2.8
Prior discussions have gone on here:

I may be in the position of getting some sponsorship for writing a hierarchy module for comments. Putting aside how the hierarchy will actually be displayed (which everyone has their own preferences for) and concentrating on the back-end handling of this feature, does anyone have any code or designs for this? Has such a module every been started and maybe not finished or released? If there is something that I can tidy up rather than starting from scratched, then that would benefit everyone.

In theory this should not be a big thing to implement, though in practice I can imagine there would be lots of places where hooks need to be put in place. Do we add the hierarchy to the comments table, or keep it completely separate, as any good module should?

How do we handle existing comments that are not part of an hierarchy? Connect them as direct children to the root node of each discussion? Or join them together in a single thread?

How should the hierarchy be stored? Is just a parent link enough, or would that be too inefficient to retrieve? What about the Celko model (left/right links, with parent links just for rebuilding the left/right links): easy to select sub-trees and related comments, but more overhead in inserting new comments?

Any notes or sketches of such a module would be most welcome.

-- Jason


  • Okay, I've produced a comment hierarchy extension anyway, allowing comments to be organised in a tree (quoting and replying to a comment will cause that comment to become a child of the original comment).

    Subversion repo for this extension is here:

    Read the readme for pre-requisites, and see how you go.

    -- Jason

    One thing I cannot work out: when a custom hidden field is submitted in the comment form, and that comment form fails to post (e.g. if posting too fast) then how does that custom hidden field get picked up and re-presented in the form on the error page? I just cannot see where the flow of logic is for that particular sequence of events.
  • I just need to add that this extension is working fine on a current live site (with the svn code listed here). If there is enough interest I will submit it to the extensions area. However, it does not look like something people are particularly interested in - or have I just caught the wrong moment?

    What this extension does, in case it is not clear, is to allow a user to reply to a specific comment (and not just to a thread) and the reply is displayed, appropriately indented, along with the comment being replied to (instead of right at the end of the discussion).

    -- Jason
Sign In or Register to comment.