Sitefinity ASP.NET CMS - Content Management System

KB Article

Home >  Support >  Knowledge Base >  KB Article
How to enable comments in the News module - ID#1070
Rating: Not rated
Last Modified: 8/4/2008
Related categories: Modules;

Article information

Article relates to

Sitefinity SP2 Hotfix 1616 

Created by

Penka Ivanova

Last modified by

 Rebecca


Enabling comments in the module administration

To enable comments in the News module administration, follow the steps below:

1. Open this template ~/Sitefinity/Admin/ControlTemplates/News/CommandPanel.ascx and add a link button with ID "commentsLink" like this:

<dt id="all"><asp:LinkButton runat="server" ID="commentsLink" Text="Comments"/></dt> 
<dd></dd

2. Copy these templates to the Sitefinity/Admin/ControlTemplates/News folder:
    ~/Sitefinity/Admin/ControlTemplates/Blogs/CommentsEdit.ascx
    ~/Sitefinity/Admin/ControlTemplates/Blogs/CommentsList.ascx
    ~/Sitefinity/Admin/ControlTemplates/Blogs/CommentsView.ascx

3. Copy the resource files of these templates which are located in the App_LocalResources folder.
 
The end result should look like this:

News article comments


Enabling comments in the public part

To enable comments in the public part, do the following:

Open ~/Sitefinity/ControlTemplates/News/Modes/ListPageDetails.ascx template and add CommentsList control. Use News View control instead of the Content View:

<%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="sfWeb" %> 
<%@ Register Assembly="Telerik.Cms.Engine" Namespace="Telerik.Cms.Engine.WebControls" TagPrefix="sfWeb" %> 
<%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Web.UI.SpamProtection" TagPrefix="sfWeb" %> 
 
<sfWeb:CssFileLink ID="CssFileLink1" FileName="~/Sitefinity/ControlTemplates/Libraries/librariesCommonLayout.css" Media="screen" runat="server" /> 
 
... 
 
<div id="comments" class="sf_postComments"
    <sfWeb:CommentsList ID="commentsList" runat="server" CssClass="sf_commentsList"
        <Template> 
            <asp:Repeater ID="commentsRepeater" runat="Server"
                <HeaderTemplate> 
                    <asp:PlaceHolder runat="server" ID="headerHolder"
                        <h2 class="sf_comments"
                            <asp:Literal ID="Literal1" runat="server" Text="Comments" /> 
                            &nbsp;<asp:Literal ID="commentsCount" runat="server"></asp:Literal> 
                        </h2> 
                    </asp:PlaceHolder> 
                    <ul class="sf_commentListing"
                </HeaderTemplate> 
                <ItemTemplate> 
                    <!-- comment goes here --> 
                    <sfWeb:CommentItem Id="anonCommentContainer" runat="server" CssClass="sf_anonymousComment" >  
                     
                     <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="date" id="commentDate" runat="server" > </abbr> 
                        </p> 
                        <asp:Label ID="text" runat="server"></asp:Label> 
                    </Template> 
                    
                    </sfWeb:CommentItem> 
                    
                    <sfWeb:CommentItem Id="authorCommentContainer" runat="server"  CssClass="sf_authorComment">  
                     <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="date" id="commentDate" runat="server"</abbr> 
                             
                        </p> 
                        <asp:Label ID="text" runat="server"></asp:Label> 
                     </Template> 
                     
                   </sfWeb:CommentItem> 
                     
                </ItemTemplate> 
                <FooterTemplate> 
                    </ul> 
                </FooterTemplate> 
            </asp:Repeater> 
            <asp:PlaceHolder ID="moderationHolder" runat="server" Visible="false"
                <class="sf_commentMessage"
                    <asp:Literal ID="Literal2" runat="server" Text="Thank you for the comment! Your comment must be approved first"></asp:Literal> 
                </p> 
            </asp:PlaceHolder> 
            <fieldset class="sf_postNewComment"
                <legend>Post a comment!</legend> 
                <ol> 
                    <li> 
                        <asp:Label ID="Label2" runat="Server" Text="Name:" AssociatedControlID="authorTxt"></asp:Label> 
                        <asp:TextBox ID="authorTxt" runat="server" ValidationGroup="commentInfo" size="30"></asp:TextBox> 
                        <asp:RequiredFieldValidator runat="server" ID="authorVal" ControlToValidate="authorTxt" 
                                ErrorMessage="Name can't be empty!" Display="dynamic" ValidationGroup="commentInfo" 
                                CssClass="sf_commentsValidator"></asp:RequiredFieldValidator> 
 
                    </li> 
                    <li> 
                        <asp:Label ID="Label3" runat="Server" Text="Email:" AssociatedControlID="emailTxt"></asp:Label> 
                        <asp:TextBox ID="emailTxt" runat="server" ValidationGroup="commentInfo" size="30"></asp:TextBox> 
                        <asp:RegularExpressionValidator runat="server" ID="emailVal" ControlToValidate="emailTxt" 
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ErrorMessage="Invalid email format!" 
                                Display="dynamic" ValidationGroup="commentInfo" CssClass="sf_commentsValidator"></asp:RegularExpressionValidator> 
                    </li> 
                    <li> 
                        <asp:Label ID="Label4" runat="Server" Text="Your URL  (<em>optional</em>):" AssociatedControlID="webSiteTxt"></asp:Label> 
                        <asp:TextBox ID="webSiteTxt" runat="server" size="30"></asp:TextBox>  
                    </li> 
                    <li class="texarea-wrapper"
                        <asp:Label ID="Label1" runat="Server" Text="Comment:" AssociatedControlID="commentTxt"></asp:Label> 
                        <asp:TextBox ID="commentTxt" runat="server" TextMode="MultiLine" ValidationGroup="commentInfo" Rows="8" Columns="40"></asp:TextBox> 
                         <asp:RequiredFieldValidator runat="server" ID="contentVal" ControlToValidate="commentTxt" 
                                ErrorMessage="Comment can't be empty!" Display="dynamic" ValidationGroup="commentInfo" 
                                CssClass="sf_commentsValidator"></asp:RequiredFieldValidator> 
                    </li> 
                    <li> 
                    <sfweb:spamprotector id="SpamProtector1" runat="server" cssclass="commentsValidator hide" 
                        validationgroup="commentInfo" enableautobotdiscovery="true" enablehiddentextboxstrategy="true" 
                        hiddentextboxerrormessage="Hidden TextBox has some text in it!" hiddentextboxlabel="Do not fill this textbox!" 
                        hiddentextboxlabelcssclass="hide" hiddentextboxinputcssclass="hide" enablemintimeoutstrategy="true" 
                        mintimeout="2" mintimeouterrormessage="Submission too fast!" /> 
                    <asp:Button ID="submitBtn" runat="server" Text="Post a comment" 
                        ValidationGroup="commentInfo" CssClass="sf_commentSubmit" /> 
                    </li> 
                </ol> 
            </fieldset> 
        </Template> 
    </sfWeb:CommentsList> 
</div> 


Article Files

  • ListPageDetails.zip



  • Article Comments

    There are no comments yet.
    Please Sign In to rate this article or to add it to your favorites.