Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ben Margevicius 6 posts 77 karma points
    Dec 02, 2019 @ 21:52
    Ben Margevicius
    0

    Getting Expired Dates from IContent

    Not really asking a question. Just putting this out there because of lack of documentation.

    In Umbraco 8. Getting expired date of content has been moved. Probably to better handle publishing of cultured content.

    Anyways myContent.ExpireDate is removed. myContent is a type of IContent you get from the content service.

    You can get the expiration by:

     var expiredate = myContent.ContentSchedule.FullSchedule.FirstOrDefault(a => a.Action == ContentScheduleAction.Expire).Date;
    

    The contructor for ContentSchedule is

    public ContentSchedule(string culture, DateTime date, ContentScheduleAction action) 
    

    So you can also query by culture if need be.

    You can see this thread for setting a expire date: https://our.umbraco.com/forum/using-umbraco-and-getting-started/99648-programmatically-set-unpublish-date

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Dec 03, 2019 @ 07:03
    Marc Goodson
    1

    Hi Ben

    We could add this to the documentation!

    The documentation for Umbraco is Open Source,

    https://github.com/umbraco/UmbracoDocs

    so you can create Issues or make PRs to add and update the information there to help others working with Umbraco.

    I'm wondering whether it would make sense to add a paragraph to this page:

    https://our.umbraco.com/Documentation/Getting-Started/Data/Scheduled-Publishing/

    about retrieving Scheduled Publishing information programatically?

    regards

    Marc

  • Ben Margevicius 6 posts 77 karma points
    Dec 04, 2019 @ 13:58
    Ben Margevicius
    0

    I guess I could write something up. When I get a second free I'll go ahead an make a pull request on this page.

Please Sign in or register to post replies

Write your reply to:

Draft