Loading...

All project content is available for reading, but you need to be a member of the project for Subversion checkout of source code, or to create/modify any information.
Login if you are a member. Apply here to request membership (open to all).

Time-controlled link collection

The Time-controlled link collection property allows editors to make links visible to end-users during specific time periods. This is very useful for example, with campaigns that will be highlighted and in focus during a limited time, then will remain published but not highlighted when the campaign is over. An editor can set up campaigns for the future and control exactly when they will be visible, by using the Time-controlled link collection.



Features

Set publishing start and stop times for the links in the Link collection

All the following properties are required:

  1. Link
  2. Start publish
  3. Stop publish

You will get an icon that tells the editor if:

  1. Page is expired/Link is not active yet
  2. Page is not visible in menu

Current version

Works for EPiServer 6 R2

Download

Available at EPiServer's Nuget feed

Installation

Install from EPiServer's Nuget feed

Configuration

No configuration is needed.

Example code

<asp:Repeater runat="server" ID="rptSummerCampaign">
        <HeaderTemplate><ul></HeaderTemplate>
    <ItemTemplate>
            <li><a href="<%# ((PageData)Container.DataItem).LinkURL %>"><%# ((PageData)Container.DataItem).PageName %></a></li>
        </ItemTemplate>
        <FooterTemplate></ul></FooterTemplate>
</asp:Repeater>



protected void Page_Load(object sender, EventArgs e)
        {
            SetAndBindTimeControlledLinkCollection();
        }

        private void SetAndBindTimeControlledLinkCollection()
        {
            if (CurrentPage["TimeControlledLinkCollectionCampaign"] == null) return;

            var relatedLinkItems = (TimeControlledLinkCollection) CurrentPage["TimeControlledLinkCollectionCampaign"];

            if (relatedLinkItems == null) return;
            relatedLinkItems = relatedLinkItems.GetValidForDate(DateTime.Now);

            if (relatedLinkItems.Count > 0)
            {
                PageDataCollection campaignPages = ToPageDataCollection(relatedLinkItems);
                if (campaignPages != null && campaignPages.Count > 0)
                {
                    FilterForVisitor.Filter(campaignPages);
                    rptSummerCampaign.DataSource = campaignPages;
                    rptSummerCampaign.DataBind();
                }
            }
        }

        public static PageDataCollection ToPageDataCollection(TimeControlledLinkCollection linkItemCollection)
        {
            var pageDataCollection = new PageDataCollection();
      
            foreach (TimeControlledLinkItem linkItem in linkItemCollection)
            {
                var url = new UrlBuilder(linkItem.Href);
                bool isEPiServerPage = PermanentLinkMapStore.ToMapped(url);

                if (isEPiServerPage)
                {
                    var page = DataFactory.Instance.GetPage(PermanentLinkUtility.GetPageReference(url));

                    if (page != null)
                    {
                        pageDataCollection.Add(page);
                    }
                }
            }
            return pageDataCollection;
        }

NOTE: Note : This example code is just for showing the concept of the TimeControlledLinkCollection. We have hardcoded the name of the property, to make it simple

Support

Tickets for this component:

No results

Ask a question

Requires login.


Report a bug

Requires login.


Add a feature request

Requires login.


Requirements

Runtime:

  • EPiServer CMS 6 and CMS 6 R2

If you want to change and compile the source code:

  • Visual Studio 2010

Contributed by

Creuna AS

Attachments