Last active
March 6, 2019 21:03
-
-
Save technomaz/aded69b4ca6d41fe93ecd7e594663f5b to your computer and use it in GitHub Desktop.
Change the publication date and associated URL for a Sitefinity News article.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Telerik.Sitefinity.Modules.News; | |
using Telerik.Sitefinity.News.Model; | |
public void ChangeNewsDate() | |
{ | |
// https://www.progress.com/blogs/how_to_publish_content_items_in_the_past | |
// https://www.progress.com/documentation/sitefinity-cms/for-developers-modify-news-items | |
var pubDate = new DateTime(2019, 02, 25); | |
var manager = NewsManager.GetManager(); | |
//var item = manager.GetNewsItem(new Guid("6aa1dc9a-58ad-45e5-b624-fe5e8267728a")); | |
var item = manager.GetNewsItems().Where(n => n.Title == "Nearly Two Hundred Serving on Missions Trips" && n.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master).FirstOrDefault(); | |
item.PublicationDate = pubDate; | |
item.Urls.Clear(); // don't keep additional URLs | |
manager.RecompileItemUrls(item); | |
manager.Lifecycle.PublishWithSpecificDate(item, pubDate); | |
manager.SaveChanges(); | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment