free geoip Community Server -- Displaying Comment Toolbar at Top and Bottom of Comment Page - Jayson's Blog - jaysonKnight.com
jaysonKnight.com
Welcome to my corner of the internet

Community Server -- Displaying Comment Toolbar at Top and Bottom of Comment Page

This post is an extension of Dave Burke’s wonderful post about making CS comment handling more like .Text.  In my case, I wanted to display the comment tool bar (BlogToolBar) at both the top and bottom of the comment feed (similar to lots of forums out there)…it’s all about flexibility right?  The second stipulation is that I only wanted to display it in both places if the post actually had replies to it (for aesthetic reasons…if there’s no comments, it looks kinda goofy having the same BlogToolBars sitting right on top of each other).  If there are no replies, only display the second BlogToolBar and hide the first one.  As I have found it to be so often in CS, the fix was trivial as the necessary components are already in place.

The first change is in Skins/Skin-EntryViewContainer.ascx:  You’ll need to add another control declaration for the second BlogToolBar (bear in mind that 2 controls of the same type must have unique ID’s), so something similar to the following:

<Blog:EntryView runat = "Server" ID = "Entry" />
<Blog:BlogPostToolBar runat = "Server" ID = "ToolBar_Top" />
<div id="comments">
<h3><CS:ResourceControl runat="server" ResourceName="Weblog_ContentList_Comments" /></h3>
<Blog:EntryComments runat = "Server" ID = "Comments" />
</div>
<div>
<Blog:BlogPostToolBar runat = "Server" ID = "ToolBar_Bottom" />
</div>

These controls are loaded dynamically at runtime by Blogs.Controls.EntryViewContainer, so you’ll need to add a new control declaration, change the name of the existing BlogToolBar control declaration, and add logic to determine if a post has any replies, like so:

    public class EntryViewContainer : WeblogThemedControl

    {

      private EntryComments comments = null;

      private EntryView entry = null;

      // jayson.knight — Display BlogToolBar at top and bottom of comment page

      // private BlogPostToolBar ToolBar = null;

      private BlogPostToolBar ToolBar_Top = null;

      private BlogPostToolBar ToolBar_Bottom = null;

 

      ...

 

      protected override void AttachChildControls()

      {

      ...

            // jayson.knight

            // ToolBar = FindControl("ToolBar") as BlogPostToolBar;

            ToolBar_Top = FindControl("Toolbar_Top") as BlogPostToolBar;

            ToolBar_Bottom = FindControl("ToolBar_Bottom") as BlogPostToolBar;

 

      ...

      }

 

      void BindData()

      {

      ...

 

                if(CurrentWeblog.EnableComments)

                {

                    comments.DataSource = ps;

                    comments.DataBind();

                }

                // jayson.knight

                // ToolBar.CurrentPost = we;

                // ToolBar.DataBind();

                ToolBar_Top.CurrentPost = we;

                ToolBar_Bottom.CurrentPost = we;

                ToolBar_Top.DataBind();

                ToolBar_Bottom.DataBind();

                if (we.Replies < 1)

                {

                    ToolBar_Top.Visible = false;

                }

                ...

      }

That’s it, you’ll now have the BlogToolBar displayed at both the top and bottom of the comment section when a post has comments on it.


Posted Apr 13 2005, 05:52 PM by Jayson Knight

4 Comments

Mat Hall wrote re: Community Server -- Displaying Comment Toolbar at Top and Bottom of Comment Page
on 04-14-2005 3:14 AM
Excellent work. Don't know if it's a Firefox funny or not, but the font size on the comments displayed while you're entering a comment is somewhat on the enormous size, but that's a minor gripe. Now that's what I call service. :)

(Actually, just checked in IE and it's the same.)
Jayson Knight wrote re: Community Server -- Displaying Comment Toolbar at Top and Bottom of Comment Page
on 04-14-2005 4:08 AM
Yeah, I noticed that as well (posted about it in an earlier entry)...it's almost like none of the CSS is being applied temporarily during the commenting process. I have bigger fish to fry at the moment (my RSS readers are screaming for some fixes), but will eventually track that down as well. Like you said, it works now...and that makes me happy :-).
Dave Burke wrote re: Community Server -- Displaying Comment Toolbar at Top and Bottom of Comment Page
on 04-14-2005 8:36 AM
Dual toolbars. A second control declaration. Ahhhh, yes. Smart! I hadn't thought of that. Nice!

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Copyright © :: JaysonKnight.com
External Content © :: Respective Authors

Terms of Service/Privacy Policy