Copied to clipboard

Flag this post as spam?

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


  • Sydney Döffert 2 posts 83 karma points
    Jan 25, 2022 @ 15:54
    Sydney Döffert
    0

    Get/Set/Edit "Main content" programatically

    Hello there,

    I want to generate pages with a lot of data fairly automated. To do so, I looked into the blueprint function of umbraco. I am happy so far, but I cant reach the "Main Content" elements.

    My Code so far: enter image description here I thought, i could access the "Main Content" elements via "GetPagedChildren" but I had no luck. The "childrens" are always 0 in count.

    How can I access these elements? enter image description here

    Thanks in advance.

  • Erik Eelman 81 posts 321 karma points
    Jan 26, 2022 @ 08:26
    Erik Eelman
    100

    Hi Sydney,

    It looks like you are using a blocklist editor on the newly created page. If i understand correctly, you actually want all the items in blocklist editor and not the children (nested pages below the new page) of the new create page.

    If you want to loop through all blocklist items, you can do something like this:

    var blocks = request.Value<IEnumerable<BlockListItem>>("myBlocksProperty"); // probably something like 'mainContent'
    foreach (var block in blocks)
    {
        var content = block.Content;
    }
    
  • Sydney Döffert 2 posts 83 karma points
    Jan 26, 2022 @ 08:39
    Sydney Döffert
    1

    Thank you very much Erik,

    thats exacly what I needed!

Please Sign in or register to post replies

Write your reply to:

Draft