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

Forums / Developing with Sitefinity / NewsView: Custom Display Problem

NewsView: Custom Display Problem

6 posts, 0 answered
  1. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    18 Dec 2009
    Link to this post
    Hi there,

    We're looking for a way to achieve the listing of news items as shown in the attached image. 

    We know of using control templates, but we're not sure if this would be possible even if we used control templates. 

    1. For the NewsArchive I would imagine it would be easy to add the words "Press Releases" behind each year and the control itself can already be configured to show only the years. 
    2. For the NewsView though we're not sure how to go about getting right was is given in the design. 

    Can anyone give some advice? 

    Regards,
    Jacques
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Dec 2009
    Link to this post
    Hi J.Hov,

    1. For the NewsArchive I would imagine it would be easy to add the words "Press Releases" behind each year and the control itself can already be configured to show only the years.

    public class ArciveControlCustom : NewsArchive
    {
        public ArciveControlCustom()
        {
        }
     
        public override string LayoutTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ArchiveTemplate.ascx";
            }
        }
     
        protected override void BindHierarchicalArchive(Telerik.Web.UI.RadTreeView tree)
        {
     
            base.BindHierarchicalArchive(tree);
            foreach (RadTreeNode node in tree.GetAllNodes())
            {
                node.Text = node.Text + "SomeText";
            }
        }
        // this is for list mode.
        protected override void BindArchive(System.Web.UI.WebControls.ListControl list)
        {
            base.BindArchive(list);
            ListItemCollection collection = list.Items;
            foreach (System.Web.UI.WebControls.ListItem item in collection)
            {
                item.Text = item.Text + "SomeText";
            }
     
        }
    }

    For the NewsView - you need a new control, it will not be possible to use the built in NewsView. Steps and requirements

    1. Crate a class that inherits from Simple control
    2. Override LayoutTemplatePath property and set the path to your custom template.
    3. In your custom template you should have two nested repeater controls.
       - the first repeater should contain ItemTemplate where you have Literal or another appropriate control that will show the month.
       - in the ItemTemplate of the first repeater add second repeater  which will show the content items.
    4. In your custom class create control reference to the repeaters.
    5. Override InitializeControls and subscribe for the first repeater ItemDataBound event
    6. Bind the months. You can use an enum where you will add all months from January to December.
    7. Find the second repeater using e.Item.FindControl method.
    8.  Bind the second repeater. Here you need to get all content items from News provider. Then get the IContent Publication_Date metadate using GetMetaDate method. Parse the date and get the months only. Then using the enum check whether there is a content item for a given month. If there are not any content items , just hide the control that shows the month.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    18 Dec 2009
    Link to this post
    Hi Ivan, thanks for the reply.

    I must say I'm totally lost. Admittedly this is one area where myself and our team do feel overwhelmed when it comes to Sitefinity. 

    Those steps that you provided... what are you actually creating when you do that? 
    I know in Sitefinity you can build
    1. Custom Controls (User Controls)
    2. Modules
    3. Control Designers

    I'm sure there are more, but this is where things get confusing. 

    Any help would be appreciated. 

    Thanks,
    Jacques
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Dec 2009
    Link to this post
    Hi J.Hov,

    You have to create a custom control "Crate a class that inherits from Simple control". SimpleControl is a class that inherits from CompositeControl. You have to create a new control which uses News content items as data source.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    18 Dec 2009
    Link to this post
    Ok so we're talking about a Custom Control.

    And the fact that we're inheriting from Simple Control is to allow for applying different Control Designers... is that correct? 

    Regards,
    Jacques
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Dec 2009
    Link to this post
    Hello J.Hov,

    This allows you to create custom control designer.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
6 posts, 0 answered