More in this section

Forums / Developing with Sitefinity / Set Expiration Date for Module Builder item

Set Expiration Date for Module Builder item

3 posts, 0 answered
  1. Mark
    Mark avatar
    147 posts
    01 Jun 2010
    16 Apr 2012
    Link to this post
    I'm working on a job posting module and would like to allow my users to specify when their job posting should expire. How can I programatically set a date to unpublish/expire my content whenever the job posting is being persisted? 

    Any ideas?
  2. OC
    OC avatar
    129 posts
    17 Nov 2004
    17 Nov 2013
    Link to this post
    Have the same issue!

    Is there an equivalent to manager.Lifesycle.PublishOnASpesificDate ?

    I need to set expiration to dynamic module items programmatically.
  3. Vassil Vassilev
     Vassil Vassilev avatar
    308 posts
    21 Jan 2015
    18 Nov 2013
    Link to this post

    Each dynamic content item inherits IScheduleable interface thus they have ExpirationDate and PublicationDate properties. I have created a sample demo code for your convenience:

    var providerName = String.Empty;
    DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
    Type testItemType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Testmodule.TestItem");
    DynamicContent testItemItem = dynamicModuleManager.CreateDataItem(testItemType);
    testItemItem.ExpirationDate = DateTime.Now.AddDays(30);
    testItemItem.PublicationDate = DateTime.Now;

    When using dynamic items through code I advise you to use the API reference for each of your content types (code reference link, code reference) Regards,
    Vassil Vassilev
    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 Public Issue Tracking system and vote to affect the priority of the items
3 posts, 0 answered