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

Forums / General Discussions / News Module Comments in 3.6 SP1

News Module Comments in 3.6 SP1

7 posts, 0 answered
  1. Damon
    Damon avatar
    6 posts
    Registered:
    27 Jan 2009
    30 Jul 2009
    Link to this post
    Are there any detailed instructions for enabling comments in the news module for 3.6 SP1?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Jul 2009
    Link to this post
    Hi Damon,

    In your web.config file set the highlighted properties as below:

    <add name="News"  allowComments="True" commentsModeration="false" urlRewriteFormat="[Publication_Date]/[Title].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Title" securityProviderName="" allowVersioning="True" applicationName="/News" versioningProviderName=""  connectionStringName="GenericContentConnection" type="Telerik.News.Data.DefaultNewsProvider, Telerik.News.Data"/> 

    commentsModeration - when set to true the posts have to be reviewed from an administrator. Otherwise they are not visible in the front end. You can manage the comments through Sitefinity's backend.

    In your NewsView control you should also enable Comments. Go to Advanced tab >> Comments Category. There you will find the same properties - AllowComments and CommentsModeration. The properties have bool value - true/false.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Damon
    Damon avatar
    6 posts
    Registered:
    27 Jan 2009
    30 Jul 2009
    Link to this post
    By changing the web.config, I can now see comments in the back end on Modules --> News under the Tags link in the left navigation but can you be more specific about how to edit the NewsView control so users can add comments to news items?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Jul 2009
    Link to this post
    Hello Damon,

    Please take a look at the following lines

    " Go to Advanced tab >> Comments Category. There you will find the same properties - AllowComments and CommentsModeration. The properties have bool value - true/false."

    Each control in Sitefinity toolbox has edit mode from where you access presentation modes and properties.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Damon
    Damon avatar
    6 posts
    Registered:
    27 Jan 2009
    04 Aug 2009
    Link to this post
    Ok I got it working. I accessed the NewsView control by editing the listing page where the news items will be displayed and dragged the control on the page. Once I saved and published, I was able to see the news comments on that front end listing page.

    I have one more question though: Is there a way to hide the comments so that only users logged in to the site can post comments?

    Thanks in Advance.
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    05 Aug 2009
    Link to this post
    Hello Damon,

    This functionality does not come out of the box. However you can easily achieve it. I will now guide you through the steps to do it. First of all you will need to edit the template for the CommentsList control. If you have already downloaded the External Templates for Sitefinity you can find a template for the CommentsList here: ~/Sitefinity/ControlTemplates/Generic_Content/CommentsList.ascx. If you do not have the external templates for Sitefinity controls, download them from your Client.Net account, also check this blog post for more information.

    Now after you have taken the template for the CommentsList control, you can copy/paste it to ~/Sitefinity/ControlTemplates/News/, to keep up with good development practices. Open this edit for edit find the section for displaying controls related to posting comments. It starts like this:
    <h3 class="sf_commentsTitle"><asp:Literal runat="server" Text="<%$Resources:PostComment %>"></asp:Literal></h3
    <fieldset class="sf_contentCommentForm"

    Wrap the whole section within an <asp:PlaceHolder> like that:
    <asp:PlaceHolder ID="post" runat="server"
    <h3 class="sf_commentsTitle"><asp:Literal runat="server" Text="<%$Resources:PostComment %>"></asp:Literal></h3
    <fieldset class="sf_contentCommentForm"
          ... 
    </fieldset> 
    </asp:PlaceHolder> 

    Now add logic to override the control's OnLoad event to hide the placeholder you just added if the user is not logged in. Sample bellow:
    <script type="text/C#" runat="server"
        protected override void  OnLoad(EventArgs e) 
        { 
     
            if (!HttpContext.Current.User.Identity.IsAuthenticated) 
            { 
                PlaceHolder post1 = (PlaceHolder)base.FindControl("post"); 
                post1.Visible = false
            } 
            //uncomment bellow if you wish to automatically fill author name text box with name of current user 
            //else 
            //{ 
            //    ProfileBase userProfile = ProfileBase.Create(Telerik.Security.UserManager.GetCurrentUserName()); 
            //    TextBox authorText= (TextBox)((base.FindControl("post").FindControl("authorTxt"))); 
            //    authorText.Text = userProfile.GetPropertyValue("FirstName").ToString() +" "+ userProfile.GetPropertyValue("LastName").ToString(); 
            //} 
             
        } 
    </script> 

    After you have edited the template for the CommentsList, you have to "tell" your NewsView to load that edited template for comments. To do this, you have to edit the template for single news items (~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx). In that template find the tag for the comments list and edit as follows (assuming that your CommentsList template is in the folder i suggested you to copy it in):
    <div id="comments" class="sf_contentComments">    
    <sfWeb:CommentsList ID="commentsList" runat="server" CssClass="sf_commentsList"    
             LayoutTemplatePath="~/Sitefinity/ControlTemplates/News/CommentsList.ascx">     
    </sfWeb:CommentsList>    
    </div>  
     

    Lastly, you should tell your NewsView controls to use the edited template for single news items (~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx). You can do this from the edit mode of your NewsView control, go to Advanced, Appearance, and give the path to the SingleItemTemplatePath property.

    This should do the trick. If you have more questions, please feel free to contact us.

    Regards,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  7. Damon
    Damon avatar
    6 posts
    Registered:
    27 Jan 2009
    05 Aug 2009
    Link to this post
    Everything worked as expected.

    Thanks for the assistance!
    Damon
Register for webinar
7 posts, 0 answered