feedback
Jan 16 2009

Nested Comments for BlogEngine.NET

by John Dyer

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!

Comments

User 1 January 16. 2009 12:27

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.

User 1
User 3 January 16. 2009 12:31

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.

User 3
Tester January 17. 2009 08:41

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.

Tester
testing March 18. 2009 03:38

testign comment

testing
testing March 18. 2009 03:38

testing
testing March 18. 2009 03:38

testing
User 2 January 16. 2009 12:27

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.

User 2
trackback January 16. 2009 12:31

Nested/Threaded comments for BlogEngine.NET

You've been kicked (a good thing) - Trackback from DotNetKicks.com

DotNetKicks.com
Al Nyveldt January 18. 2009 22:45

This is very cool.  What an awesome feature. Smile

Al Nyveldt
Mads Kristensen January 24. 2009 09:09

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

Mads Kristensen
testing March 18. 2009 03:39

testing
panda webkinz February 2. 2009 00:16

Very interesting features! Keep up a good work!

panda webkinz
j February 5. 2009 23:04

j
j February 6. 2009 16:17

s

j
Golo Roden February 22. 2009 16:17

I am just missing words ... really great Smile!

Golo Roden
trackback April 5. 2009 22:17

BlogEngine.NET 1.5 Release Candidate available

BlogEngine.NET 1.5 Release Candidate available

Al Nyveldt
Comments are closed
Web Statistics