[BlogEngine]Enable Nested Comments

21. September 2010

5.3 - Nested Comments

BlogEngine.NET version 1.5 introduced nested comments! This allows a visitor on the blog to leave a comment addressing another person's comment. There's only three requirements to have this functionality.
1. The "Enable nested comments" checkbox on the Settings tab in the control panel must be checked.
2. The theme must have two pieces of markup in its CommentView.ascx file.

<%= ReplyToLink %>

A good place to insert this ReplyToLink markup is under the comment where the other footer links are located (Flag, AdminLinks, etc). When nested comments are supported and enabled, the ReplyToLink markup above will render a "Reply" link for each comment. When the "Reply" link for a comment is clicked, this tells BlogEngine the visitor wants to reply to this comment. Additionally, when the "Reply" link is clicked, the comment form and input fields (name, email, website, message, etc) will be re-positioned below the comment the visitor wants to reply to.

The other required markup in CommentView.ascx follows:
<div class="comment-replies" 
       id="replies_<%=Comment.Id %>" <%= (Comment.Comments.Count == 0) ? " style=\"display:none;\"" : "" %>>
       <asp:PlaceHolder ID="phSubComments" runat="server" />
</div>
You would want to place the above markup towards the bottom of CommentView.ascx -- so the nested comments are displayed after the comment being replied to.
Additionally, for the markup above, it's important the placeholder has an ID of phSubComments, the DIV has a class of comment-replies and the DIV is given the exact ID shown above.
3. CSS styles in the style.css file.
CSS styles for nested comments should be added in the theme's style.css file. In the Standard theme, the CSS defined for the comment-replies class on the DIV shown above (and related nested comments CSS) is defined as:
.comment-replies {
    backgroundtransparent url(../../pics/reply-arrow.gif) no-repeat 2px 2px;
    padding0 0 0 15px;
    margin5px 0 0 0;
}
#commentlist #comment-form {
    bordersolid 1px #ccc;
    background#fff;
    padding10px;
    margin10px 0;
}
You may of course define your own custom comment-replies CSS class in your theme's style.css file. The one shown above is designed to visually indicate the nested comment(s) are in reply to a parent comment.

From: http://blogengine.codeplex.com/wikipage?title=ThemeCreation&referringTitle=Documentation

BlogEngine.NET

Comments

hackthestockmarket
hackthestockmarket
3/2/2011 8:32:43 AM #
So that is how you cascade nested comments, I hadn't realised as mine were not displaying correctly.
5/7/2011 8:03:47 AM #
good topic for nested comments. thanks.
8/29/2011 2:16:04 PM #
thanks bud, you could my dev. time today in half :)
3/27/2012 8:43:06 AM #




Windows passwords may not be the best way to keep our computer data secure, but for most of us, they’re the best we’ve got.SO forgot the past, now one site provide you the best tutorial how to protect your data just visit our site emdadblog.com.
3/27/2012 2:49:03 PM #
5.3 - Nested Comments is the best
5/16/2012 10:26:43 AM #
i enjoy your article. great job. <a href="http://www.lsnserv.com">keep it simple</a>
5/17/2012 1:20:14 AM #
Really interesting articles. I enjoyed reading it. Are these genuine images or has the artwork been touched up they are truly. They are the best articles provided to us from manufacturers and distributors of natural vitamin supplements. They are good in the work which i have seen it.
5/18/2012 6:11:15 AM #
great post..I went over this web site and I believe you've a great deal of excellent information , saved to favorites (:.
5/18/2012 6:13:05 AM #
Thank you for taking the time to publish this information very useful!I’m still waiting for some interesting........
5/20/2012 1:05:33 AM #
Some facts in this article are really true and very useful in life.

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading