Set Expiration Date for Module Builder item

Posted by Community Admin on 04-Aug-2018 21:11

Set Expiration Date for Module Builder item

All Replies

Posted by Community Admin on 16-Apr-2012 00:00

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?

Posted by Community Admin on 17-Nov-2013 00:00

Have the same issue!

Is there an equivalent to manager.Lifesycle.PublishOnASpesificDate ?

I need to set expiration to dynamic module items programmatically.

Posted by Community Admin on 18-Nov-2013 00:00

Hello,

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
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 Public Issue Tracking system and vote to affect the priority of the items

This thread is closed