More in this section

Forums / Developing with Sitefinity / Customizing News View

Customizing News View

2 posts, 0 answered
  1. Hydo L
    Hydo L avatar
    98 posts
    Registered:
    31 Mar 2010
    18 May 2010
    Link to this post
    Hi,
    i have to display 2 latest news (Date then Summary (70 charactors), Readmore link) on home page and Datethen title then summary on next paragraph on News page.
    How can I customize the news view control for this? Which pages I need to update for this?

    Please help me. i am very new on sitefinity

    Thanks in Advance,

    Hydo.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 May 2010
    Link to this post
    Hello Hydo L,

    The control has designer from where you could set what you want to display on the master mode - when all items are listed  and details mode - when a  single item is listed. You could take a look at the attached screenshot. Under the Advanced tab of the ControlDesigner there is a category called FilterExpression. Under this category you will find a property called SortExpression. You could set it to Publication_Date DESC. This property can work only with metakeys. There is a property FilterExpression from where you could filter the datasource depending on the Publication_Date and Expiration_Date.

    If you want to switch these properties dynamically you need to create a custom control that inherits from NewsView and override CreateChildControl method where pass the values dynamically.

    sample code

    public class NewsViewCustomControl : NewsView
    {
     
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx";
            }
     
        }
     
        public override string SingleItemTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx";
            }
     
        }
     
        public override Type LocalizationAssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.LocalizationAssemblyInfo = value;
            }
        }
     
        public override Type AssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.AssemblyInfo = value;
            }
        }
     
      
        protected override void CreateChildControls()
        {
            ContentFilterBuilder filterBuilder = new ContentFilterBuilder(this);
            filterBuilder.ClearFilter();
            filterBuilder.AddFilter(new ContentFilterStatement("Publication_Date", DateTime.Now.Date.AddDays(-2).ToShortDateString(), ContentFilter.Condition.GreaterOrEqual));
     
     
            base.CreateChildControls();
             
        }
     
     
     
    }


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
2 posts, 0 answered