Copied to clipboard

Flag this post as spam?

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


  • Laurent Lequenne 123 posts 248 karma points
    Aug 28, 2017 @ 07:13
    Laurent Lequenne
    0

    New Content picker format, how to retrieve the content ?

    How to get an IPublishedContent from such data ? umb://document/dbdab1d2839d4b9a9b793b7186757918 which is how are stored the values in the new content pickers.

    content.GetValue<IPublishedContent>("field") is not working, at least not in the publishing events.

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Aug 28, 2017 @ 10:00
    Alex Skrypnyk
    0

    Hi Laurent

    You have to get IPublishedContent, like that right now, because of "Property Value Converters" is part of core after version 7.6 https://our.umbraco.org/documentation/Getting-Started/Setup/Upgrading/760-breaking-changes#property-value-converters-u4-7318

    var publishedContent = Umbraco.GetPropertyValue<IPublishedContent>("field");
    

    Or you can disable "Property Value Converters" and use old way with ids.

    Thanks,

    Alex

  • Laurent Lequenne 123 posts 248 karma points
    Sep 04, 2017 @ 10:12
    Laurent Lequenne
    0

    The Property Value Converters are disabled, and actually it's not an issue as long there is an active umbracoContext I guess.

    But in publishing events I can't get directly the items without some extra code to parse the uid and retrieve them manually.

  • David Armitage 508 posts 2078 karma points
    Sep 05, 2017 @ 11:55
    David Armitage
    0

    Hi,

    Here is some code which I used to get data from a content picker.

    if (node.GetProperty("location") != null)
    {
         IPublishedContent location = (IPublishedContent)node.GetProperty("location").Value;
    }
    

    node is also an IPublishedContent object.

    Kind Regards

    David

Please Sign in or register to post replies

Write your reply to:

Draft