More in this section

Forums / Developing with Sitefinity / Blog Post Comments Page

Blog Post Comments Page

8 posts, 0 answered
  1. Randy Bauer
    Randy Bauer avatar
    67 posts
    Registered:
    25 Sep 2009
    18 Nov 2009
    Link to this post
    I just finished giving a demo of the site that I developed and they have some changes they would like me to make.  So, how do I do the following:

    1) Change the layout of the Comment Page for the Blog Posting:
        a) Put a seperator between each comment
        b) Switch the Login Name Label and the Email Label for each comment
        c) Indent the Comments from the Actual Posting.  Right now it is all left justified.

    2) How can I auto fill the name and email of the individual who created comment?

    3) Reduce the size of the Comment box (radEditor)?

    4) Is it possible to limit who can add a comment to a post?  I have security on the page to prevent unauthorized users from accessing the page, but how do we limit who can add comments to a post?

    Basically, I need to change the way the comment page looks.

    Hopefully these aren't too many questions for one Thread.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Nov 2009
    Link to this post
    Hello Randy Bauer,

    To complete all these 4 requirements you need to create custom Commnts control and replace the existing one. As far as I see it there is not only matter of styling ( say 2 and 4)

    Steps.

    1. Map external templates for BlogPosts control - generally in this case you only need ListPageDetail.ascx template. More information about the mapping at Working with presentation modes.

    2. After  you map the template there is a Repeater - commentsRepeater control which you can style. You will also find RadEditor control declaration there. The labels for name, email , website etc are LocalResources so you can edit them in the resx file.

    3. Auto fill the name of the currently logged in user - this requres a custom control . Sample code:

    namespace Telerik.Samples
    {
        public class CustomComments : CommentsList
        {
            public CustomComments()
            {
     
            }
     
            public override string LayoutTemplatePath
            {
                get
                {
                    // REMOVE THE VALIDATORS FROM THE TEMPLATE OF OUR CUSTOM CONTROL
                    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)
            {
                if (String.IsNullOrEmpty(AuthorText.Text))
                {
                     
                    AuthorText.Text = UserManager.GetCurrentUserName();
                    // DO THE SAME FOR THE OTHER FILEDS
                     
                }
            }
     
            
        }
     
    }

    In the ListPageDetail template you need to remove the default BlogCommnets control and use the custom one.

    To restrict the comments for a give user there are two options

    1. In the code behind of ListPageDetail template check the currently logged user role and hide/show the BlogComments control. You can use UserManager class.

    2. The second option is creating a custom class that inherits from BlogPosts control. then override SetItemMetaData method and depending on the role call this.AllowComments = true/false.
    This way is better, bacause you can expose public property for your custom control from where you can set users from which role are supposed/ not supposed to enter comments.

    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.
  3. Randy Bauer
    Randy Bauer avatar
    67 posts
    Registered:
    25 Sep 2009
    19 Nov 2009
    Link to this post
    Hi Ivan,

    I am working with Sitefinity 3.7 Community addition, but we purchased a license for the full version and I just need to set this up.  Meanwhile, I'm working with this version to learn how everything works.

    Is there a difference in the versions?  For example your response:

    1. Map external templates for BlogPosts control - generally in this case you only need ListPageDetail.ascx template. More information about the mapping at Working with presentation modes.

    There is no ListPageDetail.ascx template in my project.  I started reading the "Working with presentation modes" and it also talks about other files that I am not finding in my project.  Here is the file:

    BlogPosts:
     ~/Sitefinity/Admin/ControlTemplates/BlogPosts/Design/BlogPostsControlDesigner.ascx

    Did something change with version 3.7?  Do I need the full version for this?

    Thanks,

    -R
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Nov 2009
    Link to this post
    Hi Randy Bauer,

    There is a zip archive with all templates that you can download from your account  >> downloads.

    Best wishes,
    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.
  5. Randy Bauer
    Randy Bauer avatar
    67 posts
    Registered:
    25 Sep 2009
    19 Nov 2009
    Link to this post
    Ivan,

    It looks like I need to download these templates and copy the ListPageDetail.ascx to one of my folders.  Then I need to reference it in a new file:

    Controls configuration is defined by a special file named

     

    Telerik.Sitefinity.Configuration.ControlsConfig.xml

     

    which needs to be placed in the ~/App_Data/Configuration folder of your site. The name of the file and its location are crucial for the configuration to work.

    1) Am I on the right path?
    2) Does it matter where I put the ListPageDetail.ascx file?
    3) I can then start making changes to this template file and it will replace the current template?

    Ivan,  thanks for all of your help, I really appreciate it.  Sorry for so many questions, but like most of us, this is new and I have a tight deadline.

    -R
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Nov 2009
    Link to this post
    Hello Randy Bauer,

    The templates for ContentView based controls have to mapped through the control properties as suggested at Working with presentation modes. It does not matter where you will put the templates. It does matter the path you set to be correct.

    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. Randy Bauer
    Randy Bauer avatar
    67 posts
    Registered:
    25 Sep 2009
    19 Nov 2009
    Link to this post
    Hi Ivan,

    I am getting this to work, but have an issue with getting the layout to change.  I want to change the order of the Post Author and the Post Date.  I found the code where this is displayed, but when I change it nothing changes on the page.  I can change the text "Post a Comment!" to "Post a Comment! XX" and that change does take place on the page when I refresh it.  I also want to add a seperator between the posts.

    How do I switch the Post Author and the Post Date?  Here is what I tried:

    Changed this:
    <Template> 
        <class="sf_commentAuthor">  
            <strong> 
                <asp:HyperLink ID="webSiteLink" runat="server" Visible="false" rel="nofollow"></asp:HyperLink> 
                <asp:Literal runat="Server" ID="authorName"  Visible="false" ></asp:Literal>   
            </strong> 
            <%--<abbr class="sf_commentDate" id="commentDate" runat="server"</abbr>--%> 
            <telerik:DateTimeLiteral ID="commentDateLiteral" runat="server" DateFormatString="" /> 
        </p> 
        <asp:Label ID="text" runat="server"></asp:Label> 
    </Template> 

    to this but it didn't change when I saved, restarted, and refreshed the page:
    <Template> 
        <class="sf_commentAuthor">  
            <%--<abbr class="sf_commentDate" id="commentDate" runat="server"</abbr>--%> 
            <telerik:DateTimeLiteral ID="commentDateLiteral" runat="server" DateFormatString="" /> 
            <strong> 
                <asp:HyperLink ID="webSiteLink" runat="server" Visible="false" rel="nofollow"></asp:HyperLink> 
                <asp:Literal runat="Server" ID="authorName"  Visible="false" ></asp:Literal>   
            </strong> 
        </p> 
        <asp:Label ID="text" runat="server"></asp:Label> 
    </Template> 

    Thanks,

    -R
  8. Randy Bauer
    Randy Bauer avatar
    67 posts
    Registered:
    25 Sep 2009
    19 Nov 2009
    Link to this post
    Got this to work.  I used the IE Web Developer Tools to identify what css file was being used and stumbled on the fact that the code was calling anonCommentContainer vs. authorCommentContainer.  I was assuming that author was the post author and not the blog author and that the later was being called.

    Thanks,

    Randy
Register for webinar
8 posts, 0 answered