Copied to clipboard

Flag this post as spam?

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


  • Julius Goddard 41 posts 152 karma points
    Mar 25, 2024 @ 15:58
    Julius Goddard
    0

    Umbraco 13 Equivalent to this.RenderElements for Nested Content Editor

    Hi All,

    I have recently migrated an Umbraco project from v8 to the latest v13.

    In the old v8 version - one of my pages was rendering Elements in the legacy Nested Content Editor in the following way:

        @inherits Umbraco.Web.Mvc.UmbracoViewPage<StandardContentPage>
    @{
        Layout = "layout.cshtml";
        ViewBag.BodyClass = "standardContentPage";
        this.RenderElements(Model.BodyElements, "BodyElements");
    }
    

    The back office containing the body elements looks like this:

    enter image description here

    The current template code unsurprisingly returns the following error (I am pretty sure this is because it is pre-dotnet core:

    'Views_standardContentPage' does not contain a definition for 'RenderElements' and no accessible extension method 'RenderElements' accepting a first argument of type 'Views_standardContentPage' could be found (are you missing a using directive or an assembly reference?)
    

    Is it still possible to render out elements from the Nested Content editor in Umbraco 13? - This would be a better alternative than having to restart all the elements from scratch in the Block List Editor. If so, what would be the way to do it?

    Many thanks.

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Mar 25, 2024 @ 22:26
    Marc Goodson
    100

    Hi Julius

    I think your RenderElements method isn't part of Umbraco itself but comes from this project...

    https://github.com/andemt/Limetta.Umbraco.Demo/blob/master/Limetta.Umbraco.Demo.RenderElements/Extensions/ElementExtensions.cs

    I can't see a dot net core updated version :-(

    But you can still render the content from a Nested content in Umbraco 13 with a foreach loop...

    Example halfway down this page

    https://docs.umbraco.com/umbraco-cms/v/12.latest/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/nested-content#configuring-nested-content

    Alternatively, as Nested Content will be removed in v14, you could use uSyncMigrations which has a specific conversion plan to turn Nested Content from v8+ into Block List, keeping all your content intact!

    https://github.com/Jumoo/uSyncMigrations

    Regards

    Marc

  • Julius Goddard 41 posts 152 karma points
    Mar 27, 2024 @ 12:09
    Julius Goddard
    0

    Hi Marc,

    Thanks very much for your answer.

    The foreach loop as suggested in the documentation works and renders the content on the page. I may ask a separate question later on how to render nested content within nested content which I haven't worked out yet.

    As for the uSyncMigrations - I would not recommend it - it literally did nothing - converting neither the template files, nor the document types.

    Regards,

    Julius

  • drummerboy46 27 posts 89 karma points
    Mar 28, 2024 @ 09:28
    drummerboy46
    0

    Hey Julius

    I'd recommend you give it another go, the nested/blocklist converter worked perfectly in our project. I also added my own converter for a couple of custom nuPicker properties and they converted fine too! It was a massive time saver for us.

    Did you select the option for converting from nested to blocklist in the UI?

  • Julius Goddard 41 posts 152 karma points
    Mar 28, 2024 @ 09:39
    Julius Goddard
    0

    I did, yes.

    I have now decided to re-construct everything in the block list from scratch, instead of trying to convert the nested content into block list items.

    I got quite far rendering the content from the nested content, however, it wouldn't render the nested items within the nested items for a reason that is incomprehensible to me.

    It feels like putting a square peg into a circular hole, so I don't mind starting everything again from square one; it may save me time in the long run.

  • drummerboy46 27 posts 89 karma points
    Mar 28, 2024 @ 10:34
    drummerboy46
    0

    I highly recommend you switch to BlockList or Grid. The methodology is sound and I found building templates with BlockList to be logical and easy to implement. It was also easy to customise it a little as required.

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Mar 28, 2024 @ 13:04
    Marc Goodson
    0

    Hi Julius

    You can configure the Block List to work 'inline' if you want it to look more like Nested Content.

    On the uSync Migrations front, that won't migrate the template implementation of the nested content, only the stored data into the new Block List Format.

    It's not super clear from the instructions, but you have to do a full clean export of usync content and settings first.

    Then run a Conversion

    enter image description here

    Then choose a migration plan

    enter image description here

    click Convert files

    enter image description here

    This still hasn't done anything to Umbraco yet, just updated the uSync Files on disk for settings and content to match as if they'd been entered with block list instead of nested content.

    Then import the Settings (that creates the new Block List configuration for the Nested Content inside Umbraco)

    enter image description here

    Then import the content, which migrates the content across into the new block list format.

    I've done it on quite a few sites now, and it's been pretty bang on!

    regards

    Marc

  • Julius Goddard 41 posts 152 karma points
    Mar 29, 2024 @ 07:45
    Julius Goddard
    1

    Hi Marc,

    Many thanks for taking the time to outline the steps required to operate uSync.Migrations.

    As I have already started making the elements from scratch anyway, I won't be using it this time, however, I will certainly have to migrate many more projects from old Umbraco versions in the future, so I shall certainly come back to this post.

    Regards,

    Julius

Please Sign in or register to post replies

Write your reply to:

Draft