More in this section

Forums / Developing with Sitefinity / Author comment vs. Anon comment?

Author comment vs. Anon comment?

10 posts, 0 answered
  1. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    07 Dec 2009
    Link to this post
    Greets...

    How is a author comment different form an "anon" comment? I see that there are sfWeb:CommentItem objects for anonymous comments and author comments, but I can't manage to leave a comment that will be use the "authorCommentContainer" sfWeb:CommentItem object. Could you point me in the right direction on how to make an author comment? Or of I'll have to write in some sort of detection?

    Thanks!
  2. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    07 Dec 2009
    Link to this post
    And though this could apply to any object that's generic content based, I'm specifically looking into this for the blog.
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Dec 2009
    Link to this post
    Hello Connections Academy Developer,

    BlogCommentsList which derives from CommentsList internaly gets the currently logged in user. If this user the comment owner (comment.Owner) equals to the blog owner (blog.owner) the post is marked as made from the blog author and a specific css style is applied. All other posts are marked as anonymous posts.


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  4. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    07 Dec 2009
    Link to this post
    Thanks Ivan, that makes sense. Our problem is the "owner" and the person who posts aren't the same. Is there a way to change the owner within Sitefinity? Re-creating the blog isn't an option for us. If not, would running a SQL update take care of it?
  5. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    07 Dec 2009
    Link to this post
    I think I know what I'd like to do.

    1. I'm going to create another permission level of "Blog Authors" 
    2. when there's a post from a logged-in user with that role
    3. The comment is marked as from the author

    I'm thinking I can bind to the commentsRepeater and look for comment.owners who match users that are in my role. Lets say I've done all of this already, and I have a match; how would I set the comment to be an author comment?

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Dec 2009
    Link to this post
    Hello Connections Academy Developer,

     Here is the code that you can use to change the blog owner

    BlogManager bManager = new BlogManager("Blogs");
    IBlog blog = bManager.GetBlog(new Guid("5B8A4C99-15A6-4FCC-9BC6-24672B66A688"));
    blog.Owner = "NEWNAME";

    Here is the code that you can use to change the blog post owner

    var Manager = new ContentManager("Blogs");
          var bManager = new BlogManager("Blogs");
          IBlog blog = bManager.GetBlog(new Guid("5B8A4C99-15A6-4FCC-9BC6-24672B66A688"));
          foreach (IContent cnt in blog.Posts)
          {
              IList comments = bManager.Content.GetComments(cnt.ID);
              foreach (IComment comment in comments)
              {
                  IComment getComment = bManager.Content.GetComment(comment.ID);
                  getComment.Owner = "NEWUSER";
                  bManager.Content.SaveComment(getComment);
              }
          }

    The samples above cover your last question as well.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    07 Dec 2009
    Link to this post
    I'm looking at those samples and while they change the owner, can't I bind to an event which will send the comment through the sfWeb:CommentItem Id="authorCommentContainer" instead? Or is the only way to designate a comment as an author comment to compare the comment.owner to blog.owner?
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    08 Dec 2009
    Link to this post
    Hello Connections Academy Developer,

     You can create a class that inherits from CommentsList and subscribe for button.click event of the submit button. Inside the event you can add your logic.

    namespace Telerik.Samples
    {
        public class CustomComments : CommentsList
        {
            public CustomComments()
            {
     
            }
     
            public override string LayoutTemplatePath
            {
                get
                {
                    // MAP THE EXTERNAL TEMPLATE FOR COMMENTS
                    return "~/Sitefinity/ControlTemplates/Blogs/CommentsList.ascx";
                }
            }
     
            protected override void CreateChildControls()
            {
                base.CreateChildControls();
                SubmitButton.Click += new EventHandler(SubmitButton_Click);
     
            }
     
            void SubmitButton_Click(object sender, EventArgs e)
            {
                //ADD YOUR LOGIC HERE
            }
     
            
        }
     
    }

    Finally use the customized control instead of the built in.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    08 Dec 2009
    Link to this post
    I appreciate the information Ivan, but that doesn't answer my question.

    When the comment repeater is iterating (or databinding), is there a flag I can set to designate the comment as an author comment?

  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    08 Dec 2009
    Link to this post
    Hello Connections Academy,

    You can use IsAuthorComment or create your custom Boolean type flag.


    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
10 posts, 0 answered