Copied to clipboard

Flag this post as spam?

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


  • Al 4 posts 24 karma points
    7 days ago
    Al
    0

    Umbraco 11 - Creating a Block Grid programmatically - Areas query

    Hi All, I'm in the process of migrating some very large U7 sites into v11 (18k+ articles on this one) . I've taken the approach of starting from scratch, and exporting my old content as XML and importing it into a clean v11 install with some custom import scripts.

    Generally it's going very well and i'm making excellent progress, which is lovely.

    I've got to the stage where I'm mapping my old DTGE content into the new Block Grid data type. I've managed to get everything from here working nicely:

    https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/block-editor/block-grid-editor#creating-a-block-grid-programmatically

    However in my v11 setup I'd like to use areas going forwards, and force all my blocks to be inside layout areas (simply 6-6 and 12. However the documentation above includes this:

    JsonProperty("areas")] // areas are omitted from this sample for abbreviation public object[] Areas { get; } = { };

    Clearly this is what I need to implement, rather than adding my data to the root grid editor I need to add them to areas, but Im struggling to find any examples of this being done. Any pointers?

    The layout is as follows:

    enter image description here

    So I'm looking to get my blocks inside those areas on import: enter image description here

    Currently they are just getting added into the root of the editor and outside of the areas.

    Does that make sense? Many thanks in advance.

  • Al 4 posts 24 karma points
    6 days ago
    Al
    0

    I've managed to figure most of this out by inspecting the JSON in the database. The main issue I have remaining is that each area requires a key and it looks like that key is specific to the block grids layout block area configuration. I can't however see how I would find that key programatically.

    For now i've hard coded the area keys into the import tool, so it works and puts the blocks inside the areas now.

    As you can see beloe the blocks are correctly added to the full width area.

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft