Nested Comments for BlogEngine.NET

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!

22 thoughts on “Nested Comments for BlogEngine.NET

  1. 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. 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. 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. 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. 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.

  6. 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! 😀

  7. 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

  8. 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

  9. 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.

  10. 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.

Comments are closed.