Archives Widget - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Archives Widget

  • Archives Widget
  • Hello There, I am using archives widget for my blog posts in a page I am getting the results of Month and year in a list. I want those results needs to be display like drop down navigation.

  • Hi Nagesh,

    You can extend the ArchiveControl widget, however notice that you won't be able to remove the default repeater from the control template to replace it by a DrowDownList since the ArchiveControl will expect the repeater.

    An easy approach consists on just adding the DropDownList to the template and setting Visible=false for the repeater as you can see in this short video. Then populate the DropDownList with the repeater data.

    The control template could be like this:

    <%@ Control Language="C#" %>
    <%@ Register TagPrefix="sitefinity" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" %>
     
    <script type="text/javascript">
        function redirect(url)
            this.window.location.href = url;
        
    </script>
     
    <asp:PlaceHolder ID="plhTitle" runat="server" Visible="false">
        <h2 class="sfarchiveTitle">
            <asp:Literal ID="titleLabel" runat="server"/>
        </h2>
    </asp:PlaceHolder>
     
    <asp:Repeater Visible="false" ID="rptArchive" runat="server">
        <HeaderTemplate>
            <ul class="sfarchiveList">
            
        </HeaderTemplate>
        <ItemTemplate>
            <li class="sfarchiveListItem">
             
                <sitefinity:SitefinityHyperLink ID="linkArchive" runat="server" CssClass="selectCommand sfarchiveLink"></sitefinity:SitefinityHyperLink>
             
            </li>
        </ItemTemplate>
        <FooterTemplate>
     
            </ul>
          
        </FooterTemplate>
    </asp:Repeater>
     
     
     <div class="sflanguagesDropDownList">
       <asp:DropDownList runat="server" ID="newsSel" CssClass="sflanguagesDropDown"  onchange="redirect(this.value)"></asp:DropDownList>
     </div>


    The custom ArchiveControl:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity.Modules.GenericContent.Archive;
    using Telerik.Sitefinity.Web.UI.PublicControls;
     
    namespace SitefinityWebApp.MyControls
        public class CustomArchiveWidget : ArchiveControl
        
            public override string LayoutTemplatePath
            
                get
                
                    return "~/MyControls/CustomArchiveTemplate.ascx";
                
                 
            
     
            public DropDownList NewsSelector
            
                get
                
                    return this.Container.GetControl<DropDownList>("NewsSel", false);
                
            
     
        
            protected override void ArchiveRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
            
                base.ArchiveRepeater_ItemDataBound(sender, e);
     
                ArchiveItem archive = e.Item.DataItem as ArchiveItem;
                if (archive != null)
                
                    NewsSelector.Items.Add(new ListItem(ResolveDisplayText(archive.Date), ResolveUrl(archive.Date)));
                    if (IsDateInRange(archive.Date)) NewsSelector.Items[NewsSelector.Items.Count - 1].Selected = true;
                
            
     
        



    Kind Regards,
    Junior Dominguez
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  • Hi Nagesh,

    Set the widget property ContentType to Telerik.Sitefinity.Blogs.Model.BlogPost as described in our documentation.

    http://www.sitefinity.com/documentation/documentationarticles/user-guide/widgets/navigation-widgets-group/configuring-the-archive-widget


    Kind Regards,
    Junior Dominguez
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  • Thank you so much Junior Dominguez

  • Dear Junior

    I have used the same code what u have suggested but how can I use this for BlogPosts.

    When I placed it in a blog page i am getting just dropdown there is no results of the blog post dates.

    Please help me on this

  • Dear Junior

    First of all thank u so much for your continuous support.

    I can not able to get the content type ​field in edit archives widget option.

    I used the same code and process and registered widget in tools.

    Am i doing any wrong?

  • Hi Nagesh,

    Notice that for blog posts you need to use the BlogPosts widget. Following the same procedure described in the previous message will work on your end. I recorded this other video for reference.


    Best wishes,
    Junior Dominguez
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  • Thank u so much Junior

    I appreciate your help.