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

Forums / Developing with Sitefinity / News Comments Count

News Comments Count

4 posts, 2 answered
  1. shraddha
    shraddha avatar
    87 posts
    Registered:
    18 May 2009
    21 Jul 2009
    Link to this post
    Hi,
    I am using Sitefinity- News module. In that i m using comments functionality.
    Everything is working great.
    On the news landing page i.e. in template, ListPageMaster.ascx, along with read more link I also want to display comments(n) i.e. no of comments added for that article.
    Is it possible?? Please reply.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jul 2009
    Link to this post
    Hi shraddha,

    Below is a sample control that illustrates this behavior.

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik.News.WebControls; 
    using System.Web.UI; 
     
    /// <summary> 
    /// Summary description for CustomNewsView 
    /// </summary> 
    public class CustomNewsView : NewsView 
        public CustomNewsView() 
        { 
        } 
     
        public override string ItemListTemplatePath 
        { 
            get { return "~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx"; } 
        } 
     
        public override string SingleItemTemplatePath 
        { 
            get { return "~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx"; } 
        } 
     
            protected override void SetItemContent(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem) 
           { 
            base.SetItemContent(itemContainer, contentItem); 
            var ctrl = FindContentViewControl("CommentsCount", itemContainer) as ITextControl; 
            if (ctrl !=null ) 
                ((ITextControl)ctrl).Text = GetVisibleCommentsCount(contentItem.Comments).ToString(); 
           } 

    Sincerely yours,
    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.
    Answered
  3. Nisha
    Nisha avatar
    17 posts
    Registered:
    17 Jun 2009
    22 Jul 2009
    Link to this post
    hi,
       I also want to display the "comments count" on ListPageMaster.ascx page. I have created the class  CustomNewsView.cs using above provided code and place it on App_Code folder. also add the web.config  entry in <Framework>'s  <modules> section (is it necessary to add this entry? ).What is the next step to get the Comments count?
    Waiting for the replay.

    Thanks and Regards,
    Nisha
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    22 Jul 2009
    Link to this post
    Hi Nisha,

    The provided example is a custom control. You should add it to App_Code folder of website's root. Then register the control in your web.config and use it instead of the default one.

      <toolboxControls> 
            <clear /> 
            <add name="CustomNewsView" section="Custom" type="CustomNewsView, App_Code" /> 

    I hope this helps.

    Sincerely yours,
    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.
    Answered
Register for webinar
4 posts, 2 answered