Disabling the comments on News section

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
15 Jahre weitere
Can I disabling the comments on News section or make it invisible except the approved comments
15 Jahre weitere
1) To disable comments
      a) Go to admin area, then "Content Management", then "News".
      b) Select a required news item.
      c) Check "Allow comments" checkbox
      d) Click "Save" button

2) To make it invisible except the approved comments
      a) Open News.aspx.cs file. Replace next code:

                
if (news.AllowComments)
                {
                    pnlComments.Visible = true;
                    NewsCommentCollection newsComments = news.NewsComments;
                    if (newsComments.Count > 0)
                    {
                        rptrComments.DataSource = newsComments;
                        rptrComments.DataBind();
                    }
                }
                else
                    pnlComments.Visible = false;


         with this one:

              
 NewsCommentCollection newsComments = news.NewsComments;
                if (newsComments.Count > 0)
                {
                    rptrComments.DataSource = newsComments;
                    rptrComments.DataBind();
                }
                pnlComments.Visible = news.AllowComments;




       b) Open News.aspx file. Replace next layout:
<div id="pnlComments" runat="server" style="width: 100%">
            <div class="hl">
                <img src="<%=Page.ResolveUrl("~/images/sp.gif")%>" /></div>
            <div class="blockHeader">
                <img src="<%=Page.ResolveUrl("~/images/VerticalLine.gif")%>" style="margin-top: 14px;" /><b><%=GetLocaleResourceString("NewsPage.Comments")%></b><br />
            </div>
            <div class="text1">
                <div style="float: left; padding-top: 10px;">
                    <table>
                        <tr>
                            <td style="text-align: left; vertical-align: middle;" colspan="2">
                                <strong><%=GetLocaleResourceString("NewsPage.LeaveYourComment")%></strong>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 100px; text-align: left; vertical-align: middle;">
                                <%=GetLocaleResourceString("NewsPage.CommentTitle")%>:
                            </td>
                            <td>
                                <asp:TextBox runat="server" ID="txtTitle" Width="250px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 100px; text-align: left; vertical-align: middle;">
                                <%=GetLocaleResourceString("NewsPage.CommentText")%>:
                            </td>
                            <td>
                                <asp:TextBox runat="server" ID="txtComment" TextMode="MultiLine" Height="150px" Width="250px"
                                    ValidationGroup="NewComment"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td style="text-align: left; vertical-align: middle;">
                                <asp:Button runat="server" ID="btnComment" Text="New comment" ValidationGroup="NewComment"
                                    OnClick="btnComment_Click"></asp:Button>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="hl">
                <img src="<%=Page.ResolveUrl("~/images/sp.gif")%>" /></div>
            <div class="text1">
                <asp:Repeater ID="rptrComments" runat="server">
                    <HeaderTemplate>
                        <br />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <table cellspacing="0" cellpadding="0" class="blockBordered">
                            <tbody>
                                <tr>
                                    <td style="padding: 10px;">
                                        <b>
                                            <%#Server.HtmlEncode((string)Eval("Title"))%>
                                        </b>
                                        <br />
                                        <%=GetLocaleResourceString("NewsPage.CommentsCreatedOn")%>:
                                        <%#Eval("CreatedOn")%>
                                        <br />
                                        <%#Server.HtmlEncode((string)Eval("Comment"))%>
                                        <br />
                                        <%=GetLocaleResourceString("NewsPage.CommentsFrom")%>:
                                        <%#Server.HtmlEncode(GetCustomerInfo(Convert.ToInt32(Eval("CustomerID"))))%>
                                        <br />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </ItemTemplate>
                    <SeparatorTemplate>
                        <br />
                        <br />
                    </SeparatorTemplate>
                </asp:Repeater>
            </div>
        </div>

         with this one:







      <div style="width: 100%">
            <div class="hl">
                <img src="<%=Page.ResolveUrl("~/images/sp.gif")%>" /></div>
            <div class="blockHeader">
                <img src="<%=Page.ResolveUrl("~/images/VerticalLine.gif")%>" style="margin-top: 14px;" /><b><%=GetLocaleResourceString("NewsPage.Comments")%></b><br />
            </div>
            <div class="text1">
                <div style="float: left; padding-top: 10px;">
                    <table id="pnlComments" runat="server" >
                        <tr>
                            <td style="text-align: left; vertical-align: middle;" colspan="2">
                                <strong><%=GetLocaleResourceString("NewsPage.LeaveYourComment")%></strong>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 100px; text-align: left; vertical-align: middle;">
                                <%=GetLocaleResourceString("NewsPage.CommentTitle")%>:
                            </td>
                            <td>
                                <asp:TextBox runat="server" ID="txtTitle" Width="250px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 100px; text-align: left; vertical-align: middle;">
                                <%=GetLocaleResourceString("NewsPage.CommentText")%>:
                            </td>
                            <td>
                                <asp:TextBox runat="server" ID="txtComment" TextMode="MultiLine" Height="150px" Width="250px"
                                    ValidationGroup="NewComment"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td style="text-align: left; vertical-align: middle;">
                                <asp:Button runat="server" ID="btnComment" Text="New comment" ValidationGroup="NewComment"
                                    OnClick="btnComment_Click"></asp:Button>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="hl">
                <img src="<%=Page.ResolveUrl("~/images/sp.gif")%>" /></div>
            <div class="text1">
                <asp:Repeater ID="rptrComments" runat="server">
                    <HeaderTemplate>
                        <br />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <table cellspacing="0" cellpadding="0" class="blockBordered">
                            <tbody>
                                <tr>
                                    <td style="padding: 10px;">
                                        <b>
                                            <%#Server.HtmlEncode((string)Eval("Title"))%>
                                        </b>
                                        <br />
                                        <%=GetLocaleResourceString("NewsPage.CommentsCreatedOn")%>:
                                        <%#Eval("CreatedOn")%>
                                        <br />
                                        <%#Server.HtmlEncode((string)Eval("Comment"))%>
                                        <br />
                                        <%=GetLocaleResourceString("NewsPage.CommentsFrom")%>:
                                        <%#Server.HtmlEncode(GetCustomerInfo(Convert.ToInt32(Eval("CustomerID"))))%>
                                        <br />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </ItemTemplate>
                    <SeparatorTemplate>
                        <br />
                        <br />
                    </SeparatorTemplate>
                </asp:Repeater>
            </div>
        </div>
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.