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

Forums / Designing & Styling / Archives Widget

Archives Widget

8 posts, 1 answered
  1. Nagesh
    Nagesh avatar
    9 posts
    Registered:
    01 Jul 2014
    09 Jul 2014
    Link to this post

    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.

    Answered
  2. Junior Dominguez
    Junior Dominguez avatar
    115 posts
    Registered:
    08 Dec 2016
    12 Jul 2014
    Link to this post
    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
     
  3. Nagesh
    Nagesh avatar
    9 posts
    Registered:
    01 Jul 2014
    14 Jul 2014 in reply to Junior Dominguez
    Link to this post

    Thank you so much Junior Dominguez

  4. Nagesh
    Nagesh avatar
    9 posts
    Registered:
    01 Jul 2014
    14 Jul 2014 in reply to Junior Dominguez
    Link to this post

    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

  5. Junior Dominguez
    Junior Dominguez avatar
    115 posts
    Registered:
    08 Dec 2016
    14 Jul 2014
    Link to this post
    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
     
  6. Nagesh
    Nagesh avatar
    9 posts
    Registered:
    01 Jul 2014
    15 Jul 2014 in reply to Junior Dominguez
    Link to this post

    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?

  7. Junior Dominguez
    Junior Dominguez avatar
    115 posts
    Registered:
    08 Dec 2016
    15 Jul 2014
    Link to this post
    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
     
  8. Nagesh
    Nagesh avatar
    9 posts
    Registered:
    01 Jul 2014
    16 Jul 2014 in reply to Junior Dominguez
    Link to this post

    Thank u so much Junior

    I appreciate your help.

8 posts, 1 answered