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

Forums / Developing with Sitefinity / News date archive

News date archive

2 posts, 0 answered
  1. Anthony Smith
    Anthony Smith avatar
    34 posts
    Registered:
    08 Dec 2009
    13 Jan 2010
    Link to this post
    Hi,

    We are assessing the news date archive facility, however have concerns over how the url is displayed i.e. /news?Year=2010&Month=1 is there a way in which we can rewrite this so it appears /news/2010/January as part of SF?

    Many thanks,

    Anthony
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Jan 2010
    Link to this post
    Hi Anthony Smith,

    It is possible, but it will require to override several methods from NewsArchive class and NewsView class.

    1.NewsArchive

    public class ArciveControlCustomToolboxItem : ToolboxItem
    {
        public ArciveControlCustomToolboxItem()
            : base(typeof(ArciveControlCustom))
        {
            base.DisplayName = "ArciveControlCustomToolboxItem";
            base.Description = "ArciveControlCustomToolboxItem";
        }
    }
     
    [System.ComponentModel.ToolboxItem(typeof(ArciveControlCustomToolboxItem))]
    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";
                node.NavigateUrl = node.NavigateUrl + "&" + "HERE ADD THE NEWSCATID QUERYSTIRING";
            }
        }
     
     
     
     
        // 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";
                item.Value = item.Value + "&" + "HERE ADD THE NEWSCATID QUERYSTIRING";
            }
     
        }
    }

    2. NewsView class - Here you have to override CreateChildControls and use ContentFilterbuilder before calling the base.

    Kind 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.
2 posts, 0 answered