Nested Comments for BlogEngine.NET

January 16, 2009 | .NET | 33 Comments

There are some great changes coming for BlogEngine.NET 1.5.0.0, and one of them is nested comments! I checked in the changes to Codeplex just last night, and I’ve implemented them here as a demo while we hammer out the final details.

Nested (or threaded) comments have been added to a lot of blog platforms lately (including WordPress 2.7), and it is a major feature of comment plugins like Disqus and Intense Debate. I personally think threaded comments make longer posts with lots of comments make a lot more sense.

Here’s an example of how a the comments in a recent post of mine make a lot more sense after turning on nesting. Since I responded in bursts to comments, they were out of order, but with nesting you can see that my comment (in dark brown) are now contextually nested and make much more sense. (Note: To make this work, I had to go back and manually add the “parentid” attribute to my comments to make them nested.)

Before (not nested)

After (nested)

Not nested Not Nested

 

If you want to try it out, you can try it on this post or download the latest check-in from Codeplex. Just be warned that this isn’t the final release. There may be some quirks in the JavaScript.

To add nesting to your existing themes, you’ll need to add the following code (marked by HTML comments) from the Standard Theme:

<div id="id_<%=Comment.Id %>" class="vcard comment<%= Post.Author.Equals(Comment.Author, StringComparison.OrdinalIgnoreCase) ? " self" : "" %>">
<p class="date"><%= Comment.DateCreated %> <a href="#id_<%=Comment.Id %>">#</a></p>
<p class="gravatar"><%= Gravatar(80)%></p>
<p class="content"><%= Text %></p>
<p class="author"> <%= Comment.Website != null ? "<a href=\"" + Comment.Website + "\" class=\"url fn\">" + Comment.Author + "</a>" : "<span class=\"fn\">" +Comment.Author + "</span>" %>
<%= Flag %>
<%= ((BlogEngine.Core.BlogSettings.Instance.IsCommentNestingEnabled && Comment.IsApproved) ? " | " : "") %>
<%= ReplyToLink %> <!—- add this for reply to links –>
<%= AdminLinks %>
</p> </div>
<!—- Start: threading –>
<div class="comment-replies" id="replies_<%=Comment.Id %>" <%= (Comment.Comments.Count == 0) ? " style=\"display:none;\"" : "" %>>
<asp:PlaceHolder ID="phSubComments" runat="server" />
</div>
<!—- End: threading –>

Hope you like it, and let me know if you implement it on your site!

33 responses to “Nested Comments for BlogEngine.NET”

  1. User 1 says:

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque convallis nisl nec mauris. Nullam dapibus turpis quis elit. Nam metus. Fusce nec elit sodales massa interdum condimentum. Nulla accumsan dignissim orci. Suspendisse commodo magna at libero. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc ac arcu a est semper imperdiet. Sed id felis. Cras feugiat. Aliquam magna. Integer turpis ligula, convallis at, blandit non, ornare quis, nisi. Nunc vel ante quis lorem fringilla rutrum.

  2. User 2 says:

    Comment #2: Nulla accumsan dignissim orci. Suspendisse commodo magna at libero. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc ac arcu a est semper imperdiet. Sed id felis. Cras feugiat. Aliquam magna. Integer turpis ligula, convallis at, blandit non, ornare quis, nisi. Nunc vel ante quis lorem fringilla rutrum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque convallis nisl nec mauris. Nullam dapibus turpis quis elit. Nam metus. Fusce nec elit sodales massa interdum condimentum.

  3. User 3 says:

    Comment #3 (nested): Nam metus. Fusce nec elit sodales massa interdum condimentum. Nulla accumsan dignissim orci. Suspendisse commodo magna at libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque convallis nisl nec mauris. Nullam dapibus turpis quis elit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc ac arcu a est semper imperdiet. Sed id felis. Cras feugiat. Aliquam magna. Integer turpis ligula, convallis at, blandit non, ornare quis, nisi. Nunc vel ante quis lorem fringilla rutrum.

  4. Tester says:

    Suspendisse commodo magna at libero. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc ac arcu a est semper imperdiet. Sed id felis. Cras feugiat. Aliquam magna. Integer turpis ligula, convallis at, blandit non, ornare quis, nisi.

  5. Al Nyveldt says:

    This is very cool. What an awesome feature. :)

  6. This is much cooler than I imagined it could be. Great job, John!

  7. Golo Roden says:

    I am just missing words … really great :-)!

  8. testing says:

    testign comment

  9. Dieran Blog says:

    Hi…Your post really got me thinking man….. an intelligent piece ,I must say.

  10. Great nested comments trick on the Blogengine platform. Will be applying it to my blog. =)

  11. Hey John, I’ve been looking this nested code for couple of hours ago. I will try to implement this code on my website (college project) and hope this will working.

  12. Ok great! Tested it and it’s working! I don’t know how to thank to you anymore, you just saved my life! Thank you! Thank you! Thank you! 😀

  13. Betty Clark says:

    I have read a lot of the comments and I just wonder why people say the things they do, I mean they can find the bad in anything. I guess that is where we are in this world. Just hurt hurt hurt, no matter what the subject is. Lawrence Williams http://www.trybw.com Fort Myers, Naples, Bonita,Cape Coral Computer Repair Service

  14. tiffany says:

    Good post Thank for sharing.

  15. Thanks for the post but, I would like to see more features added to the next release of BE such as a photo gallery/slide show built in and comment administration

  16. terima kasih (thank you) it’s something new for me. i’ll try it

  17. Every customer on Amazon has registered; you cant buy without first registering.
    She used to go through in details the photos of her childhood.
    Only when a customer is searching for a product that Amazon doesnt stock will they find,
    or even consider, your offer because Amazon owns the customer relationship.

  18. Helpful information. Lucky me I found your website
    by accident, and I am stunned why this twist of fate didn’t came about earlier!
    I bookmarked it.

    Here is my blog: Zegary reklamowe jako skuteczne prezenty (http://www.upominki-reklamowe.biz.pl/zegary-reklamowe-jako-skuteczne-prezenty)

  19. Thanks designed for sharing such a fastidious thought,
    piece of writing is nice, thats why i have read it entirely

  20. Article writing is also a excitement, if you be acquainted with afterward you can write if not it is complicated to
    write.

  21. loss product says:

    It’s an amazing article for all the web people; they
    will take benefit from it I am sure.

  22. Josh says:

    My family all the time say that I am wasting my time here at net, but
    I know I am getting knowledge all the time by reading thes nice content.

  23. Heya i’m for the first time here. I found this board and I
    find It truly useful & it helped me out a lot.
    I’m hoping to offer something back and aid others such as you helped
    me.

  24. gods herbs says:

    Hello everyone, it’s my first go to see at this web page,
    and post is actuallly freuitful in favor of me, keep up posting tyese types of posts.

    my site gods herbs

  25. Hello, i think that i noticed you visited my weblog so
    i got here to return the desire?.I’m trying to to find issues to enhance
    my website!I suppose its adequate to make use of some of your ideas!!

  26. If some one desires expert view on the topic of running a blog afterward i suggest him/her to pay
    a visit this blog, Keep up the good work.

  27. short Url says:

    Its such as you lesarn my thoughts! You seem to grasp so much about this,
    like you wrote the e bbook inn it or something. I think that you
    simply could do with a few % to power the message houe
    a little bit, however other than that, that iis magnificent blog.
    A great read. I will certainly be back.

    Allso visit my web-site – short Url

  28. Truly no matter if someone doesn’t understand then its up
    to other people that they will assist, so here it takes place.

  29. shopping says:

    It is in point of fact a nice and useful piece of info.
    I’m glad that you shared this helpful info with us.

    Please stay us informed like this. Thanks for sharing.

Leave a Reply

Hi, I'm John Dyer. In my day job, I build websites and create online seminary software for a seminary in Dallas. I also like to release open source tools including a pretty popular HTML5 video player and build tools that help people find best bible commentaries and do bible study. And just for fun, I also wrote a book on the theology of technology and media.

Fork me on GitHub

Social Widgets powered by AB-WebLog.com.