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 3945 posts 15163 karma points MVP 10x admin c-trib
    Jul 09, 2020 @ 10:52
    Lee Kelleher
    100

    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~

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies