The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
As usual, we’ve packed a lot of fixes and improvements in the just released 4.2 SP1 of Sitefinity. If you still haven’t checked it out, go download it from your account. With this blog post, I want to highlight a feature we’ve implemented that was requested a lot. From now on, you can publish any content in Sitefinity with a date in the past.
Lots of people asked us to implement this, and we listened. A common scenario we’ve heard about is importing content from an existing news site into Sitefinity, and keeping the dates of news articles. This is now possible.
When creating an item, instead of clicking the Publish button directly, you can choose another option from the “More Actions” menu:
This would bring up a dialog, where you can select any date for publishing the news item, including ones in the past.
Although this is handy, I admit there will be a lot of scenarios, where this work will not be done through the user interface. Many people have written custom code to import content using the Sitefinity API. We’ve also made it very easy to specify a past date for items created through code.
var pubDate =
new
DateTime(1978, 4, 15);
var manager = NewsManager.GetManager();
var item = manager.CreateNewsItem();
item.Title =
"News item in the past"
;
item.UrlName =
"past-news"
;
item.Content =
"This item is created through the native API"
;
manager.RecompileItemUrls(item);
manager.Lifecycle.PublishWithSpecificDate(item, pubDate);
manager.SaveChanges();
And also, here’s how you can do the same using the fluent API:
App.WorkWith().AnyContentItem<NewsItem>().CreateNew().Do(
n =>
{
n.Title =
"Sample item in past"
;
n.UrlName =
"sample-item-in-past"
;
})
.Publish(
new
DateTime(1978, 4, 15))
.SaveChanges();
Go ahead and try this new feature. We are open to other suggestions to include in the next releases. The more you vote on items in PITS, the faster you get them.
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.