News Publication Date

Posted by Community Admin on 04-Aug-2018 09:51

News Publication Date

All Replies

Posted by Community Admin on 13-Mar-2012 00:00

I have a new site an must copy over the news from the past years.

Am I wrong or is there still no way to set a publication date on News.

How do you sort news by publication date?

Markus

Posted by Community Admin on 14-Mar-2012 00:00

Anyone?

Markus

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

Hello Markus,

You can check this blog post out which explains how you can publish any content item in Sitefinity with a past date, I believe you might find it useful. I've also prepared a small sample for you which you can use directly in code if you want to schedule your news item:

public void ScheduleNewsItem(string newsTitle, string newsContent, DateTime publicationDate, DateTime expirationDate)
       
           NewsManager nManager = NewsManager.GetManager();
           var newsItem = nManager.CreateNewsItem();
 
           newsItem.Title = newsTitle;
           newsItem.Content = newsContent;
           SummarySettings newsSummarySettings = new SummarySettings(SummaryMode.Words, 20, false, false);
           newsItem.Summary = SummaryParser.GetSummary(newsContent, newsSummarySettings);
           newsItem.AllowComments = false;
           newsItem.Visible = true;
           //You need to set the UrlName and replace any special characters,  the manager will take care of recompiling the item URL
           newsItem.UrlName = Regex.Replace(newsItem.Title.ToLower(), UrlNameCharsToReplace, UrlNameReplaceString);
           newsItem.PublicationDate = publicationDate;
           newsItem.ExpirationDate = expirationDate;
           //The item needs to be chacked out so we can pass it to WorkflowManager for scheduling
           nManager.CheckOut(newsItem);
           nManager.SaveChanges();
 
           var bag = new Dictionary<string, string>();
           bag.Add("ContentType", typeof(NewsItem).FullName);
           WorkflowManager.MessageWorkflow(newsItem.Id, typeof(NewsItem), null, "Schedule", true, bag);
       


Regards,
Boyan Barnev
the Telerik team
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

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

Dear Boyan

Thanks for the feedback. It's ok to have a workaround but I would never have guessed to use a publish unpublish date to set a news date.

Markus

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

Hi Markus,

Thank you for getting back to me. Maybe I didn't get your question correctly, can you please elaborate in some more details on the exact use case scenario that you're going to implement, as we have extended the functionality for setting Content items publication date to include almost all possible scenarios, and will be glad to assist you in using it.

Regards,
Boyan Barnev
the Telerik team

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