Copied to clipboard

Flag this post as spam?

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


  • stephencai 21 posts 131 karma points
    Jul 09, 2020 @ 08:49
    stephencai
    0

    IContent To IPublishedContent

    Guys,

    Currently, I am facing a big issue about preview function. I am using react as my frontend part, but i also need to support preview mode. I can get the "latest" version of data, but it is Icontent type, many function is missing or hard to find (not like ipublishedcontent).

    Any idea how to convert the IContent object to Ipublishedcontent??

    Thanks~

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jul 09, 2020 @ 10:52
    Lee Kelleher
    101

    Hi Stephen,

    Are you using Umbraco 7 or 8?

    If it's Umbraco 8, then you can pass the preview parameter as true to the API call.

    e.g.

    var content = UmbracoContext.Content.GetById(true, 1234);
    

    That will give you the latest draft (saved, no published) content.

    For v7, it's not as straight-forward, but there are code solutions that may help convert IContent to IPublishedContent. I'm happy to share.

    Cheers,
    - Lee

  • stephencai 21 posts 131 karma points
    Jul 13, 2020 @ 04:29
    stephencai
    0

    I am using 8. Oh Thanks Kelleher, it works now~

  • Alexander Tkacuk 19 posts 120 karma points
    Apr 12, 2021 @ 12:01
    Alexander Tkacuk
    0

    you get with this aproatch unpublished content as IPublishedContent but..... all children collections have only published result.

Please Sign in or register to post replies

Write your reply to:

Draft