John Dyer

Technology and web development in curly bracket languages {Javascript, C#, ActionScript}

Nested Comments for BlogEngine.NET

by John Dyer 16. January 2009 21:03

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

1/16/2009 9:27:02 PM # User 1 User 1 United States | Reply
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.
1/16/2009 9:31:05 PM # User 3 User 3 United States | Reply
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.
1/17/2009 5:41:58 PM # Tester Tester United Kingdom | Reply
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.
3/18/2009 12:38:07 PM # testing testing Peru | Reply
testign comment
3/18/2009 12:38:25 PM # testing testing | Reply
3/18/2009 12:38:56 PM # testing testing | Reply
1/16/2009 9:27:32 PM # User 2 User 2 United States | Reply
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.
1/16/2009 9:31:52 PM # trackback DotNetKicks.com | Reply
Nested/Threaded comments for BlogEngine.NET

You've been kicked (a good thing) - Trackback from DotNetKicks.com
1/24/2009 6:09:41 PM # Mads Kristensen Mads Kristensen Denmark | Reply
This is much cooler than I imagined it could be. Great job, John!
3/18/2009 12:39:06 PM # testing testing | Reply
5/29/2010 2:14:18 PM # Dieran Blog Dieran Blog | Reply
Hi...Your post really got me thinking man..... an intelligent piece ,I must say.
6/9/2010 8:23:44 PM # best ipad apps best ipad apps United States | Reply
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.
best ipad apps's last post: msblogs.com/.../#comment-1323" rel="nofollow">Comment on Microsoft Surface Computing by Callaz3
6/9/2010 8:32:54 PM # best ipad apps best ipad apps United States | Reply
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! Laughing
best ipad apps's last post: www.bestipadappslist.com/.../" rel="nofollow">List of Best iPad Apps
6/21/2010 1:41:32 PM # Betty Clark Betty Clark United States | Reply
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  www.trybw.com  Fort Myers, Naples, Bonita,Cape Coral  Computer Repair Service
6/30/2010 11:38:18 AM # tiffany tiffany United States | Reply
Good post Thank for sharing.
7/1/2010 5:21:58 PM # sevenseasspasalon sevenseasspasalon United States | Reply
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
7/6/2010 6:15:06 PM # Techno Mix Music Techno Mix Music United States | Reply
Good post...Thanks for sharing...bookmarked it...Tested it and it's working

Thanx
Techno Mix Music's last post: musicddl.net/.../#comment-363" rel="nofollow">Comment on VA – Progressive House Collection 19 (2010) by soulroot
7/10/2010 1:42:52 AM # iphone 4 case iphone 4 case United States | Reply
I'm sorry, this is quite hard for me, do you have video tutorial for this one? THanks in advance!
iphone 4 case's last post: www.iphone4gcases.org/.../" rel="nofollow">Featured: iPhone 4 Case Store
7/15/2010 9:33:49 AM # no fee work at home jobs no fee work at home jobs United States | Reply
blogging is always a good way to explore your ideas and view for entire world...And commenting for such nice post is also necessary...it consider like an appreciation
7/17/2010 8:13:54 AM # Dissertation help Dissertation help United Kingdom | Reply
Its great to see that people are sharing quite profitable information with each other and now we can move our selves to a new era.
7/30/2010 9:52:23 AM # electronic cigarette electronic cigarette United States | Reply
orem 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.
electronic cigarette's last post: www.electroniccigarettehub.com/.../...althier.html" rel="nofollow">Electronic Cigarettes - A Healthier Alternative To Smoking

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Web Statistics