Skip to content

Instantly share code, notes, and snippets.

@technomaz
Last active March 6, 2019 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technomaz/aded69b4ca6d41fe93ecd7e594663f5b to your computer and use it in GitHub Desktop.
Save technomaz/aded69b4ca6d41fe93ecd7e594663f5b to your computer and use it in GitHub Desktop.
Change the publication date and associated URL for a Sitefinity News article.
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