1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / How To Update News Publication Date?

How To Update News Publication Date?

4 posts, 0 answered
  1. waqar
    waqar avatar
    76 posts
    Registered:
    28 Mar 2011
    16 Sep 2011
    Link to this post
    Hi Everyone!

    Can you please tell me how can I modify the publication date of the news items?
    I allowed the PublishDate to visible from custom field options and it is displaying on the edit mode of news but when I update the publish date it does not update.I am using sitefinity 4.1 SP3.
    Can you please reply ASAP.

    Thanks!

  2. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    17 Sep 2011
    Link to this post
    Hi Waqar,

    Try this extension method:

    public static void SetPublicationDate(this Content item, IContentLifecycleManager manager, DateTime publicationDate)
    {
        var liveItem = manager.GetLive(item);
        liveItem.PublicationDate = publicationDate;
     
        var masterItem = manager.GetMaster(item);
        masterItem.PublicationDate = publicationDate;
    }

    And then after you call the Publish method of the content manager call

    ((Content)newsItem).SetPublicationDate(manager, publicationDate);
    manager.SaveChanges();

    All the best,
    Lubomir Velkov
    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
  3. Kevin
    Kevin avatar
    38 posts
    Registered:
    06 Sep 2011
    08 Nov 2011
    Link to this post
    Lubomir,
    Could I get some more information on this solution?

    The code you've provided; do we add this to the code-behind on the page the news widget in included?

    Just how do I implement this?

    Kevin
  4. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    10 Nov 2011
    Link to this post
    Hello Kevin,

    This code is used to manually update the Publication date. If you want a solution that allows you to modify it from the Backend then this is not going to work.

    All the best,
    Lubomir Velkov
    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
4 posts, 0 answered