+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / BlogCommentsList binding data

BlogCommentsList binding data

5 posts, 0 answered
  1. Gayan Perera
    Gayan Perera avatar
    7 posts
    Registered:
    24 Apr 2010
    16 Nov 2010
    Link to this post
    Hi

    We've created a custom control and added it to the blog page, it shows up but it doesn't display the comments for the current blog entry.

    Our control is called "example.ascx" it's an exact copy of the out of the box "ContentViewSingleItem.ascx" with the post removed and leaving only the <sfWeb:BlogCommentsList ...> tag there.

    However it's not binding the comments, please see this page
    http://www.magnetism.co.nz/blog/cindy/10-03-22/Using_Advanced_Find_to_List_all_the_Microsoft_CRM_E-mail_Records_with_Unresolved_E-mail_Addresses.aspx

    As you can see you can see the comment is displayed on the top part which is the out of the box "ContentViewSingleItem.ascx" but our custom control which is at the bottom of the page doesn't display the comment

    How do I tell it to bind the data?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Nov 2010
    Link to this post
    Hello Gayan,

    1. Allow Comments for blogs provider should be enabled.
    2. CommentsList control works together with BlogPosts control
    Inside BlogPosts control we set the parent of the comment item - where you comment
    item will be saved. Most probably there is no parent id set in your control and the form is not saved.

    Since your custom contorl is just a form with RadEditor and the same fields
    I suggest that

    1. Get the content item ID from the Query String

    var Manager = new ContentManager("Blogs");
    if (Context.Items.Contains(Manager.Provider.ContentItemKey))
    itemId = (Guid)((IUrlRewriteData)Context.Items[Manager.Provider.ContentItemKey]).Data;


    2. Subscribe for Click event ( or use command ) of your button
    3. Use the API to create a comment for your post

    sample

    protected void SubmitButton_Command(object sender, CommandEventArgs e)
           {
               
               if (Page.IsValid && this.ParentID != Guid.Empty)
                {
                       var conent = Manager.GetContent(itemID)
                       IComment comment = this.Manager.CreateComment(content);
     
                       comment.Text = this.CommentText.Content;
                       comment.Author = this.AuthorText.Text;
                       comment.Email = this.EmailText.Text;
                       comment.Owner = SecurityManager.GetCurrentUserName();
     
                       this.Manager.SaveComment(comment);
     
                        
                   }
                    // here clean the form            
         }


    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Gayan Perera
    Gayan Perera avatar
    7 posts
    Registered:
    24 Apr 2010
    16 Nov 2010
    Link to this post

    Thanks for the quick reply Ivan

    2. CommentsList control works together with BlogPosts control
    Inside BlogPosts control we set the parent of the comment item - where you comment
    item will be saved. Most probably there is no parent id set in your control and the form is not saved.


    How do I set this? at this stage all I want to do is display the comments inside my custom control

    I've tried the code below but doesn't bind any comments

                Telerik.Cms.Engine.ContentManager cm = new Telerik.Cms.Engine.ContentManager("Blogs");
                if (Context.Items.Contains(cm.Provider.ContentItemKey))
                {
                    var itemId = (Guid)((Telerik.Web.IUrlRewriteData)Context.Items[cm.Provider.ContentItemKey]).Data;
                    var items = cm.GetComments(itemId);

                    Repeater commentsRepeater = (Repeater)Find(this.commentsList, "commentsRepeater");
                    commentsRepeater.DataSource = items;
                    commentsRepeater.DataBind();
                }

     

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Nov 2010
    Link to this post
    Hi Gayan,

    You have to use Manager.GetComments method where you can pass the content ID for which you want to retrieve the comments.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Gayan Perera
    Gayan Perera avatar
    7 posts
    Registered:
    24 Apr 2010
    16 Nov 2010
    Link to this post
    Ahh ok, I think I finally got my head around how SiteFinity works, I've created my own repeater instead of tryign to use the Telerik BlogCommentsList control and bound the comments using GetComments

    Thanks for the help
Register for webinar
5 posts, 0 answered