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
    Apr 25, 2019 @ 16:40
    Ben Margevicius
    0

    Saving nested content

    Nested content introduced a new interface IPublishedElement. How do we create and save nested content in Umbraco 8 through a controller? It appears that Serializing a List<Dictionary<string, object>> to json doesn't work.

  • Thomsen 113 posts 336 karma points
    Apr 25, 2019 @ 19:42
    Thomsen
    0

    Please look at Davids answer in this answer for Umbraco 7. I have it working in V8 as well with a little workaround.

    https://our.umbraco.com/packages/backoffice-extensions/nested-content/nested-content-feedback/88895-creating-nested-content-programatically

    As stated in the last comment in the thread, you have to make sure that the property is not empty, otherwise you cannot save anything to it - it simply does not exist yet.

    My workaround was to save an empty dummy dictionary item on the property on content creation or if the property is null, to make the property "exist". Then, when saving the real nested content dictionary items to the property I remove the first item in the dictionary list (the dummy item) prior to adding the new items.

    Not pretty but it works as a temporary solution, until hopefully fixed (maybe on Tuesday with the v8.0.2 update, who knows.)

  • MarcC 49 posts 356 karma points
    Jul 17, 2019 @ 06:34
    MarcC
    0

    Do you have an example of this please?

  • Stherm 16 posts 86 karma points
    Jul 18, 2019 @ 18:36
    Stherm
    0

    I would like to have an example on how you got it to work, if it's possible.

    Thanks

  • Andrew Hawken 59 posts 116 karma points c-trib
    Aug 20, 2019 @ 14:46
    Andrew Hawken
    0

    Does anyone know if there is a more formal/documented way of doing this yet?

  • Ben Margevicius 6 posts 77 karma points
    Aug 20, 2019 @ 15:13
    Ben Margevicius
    1

    I wrote up a post in Umbraco's github on how to do this. https://github.com/umbraco/Umbraco-CMS/issues/5348

Please Sign in or register to post replies

Write your reply to:

Draft