Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 900 posts 2449 karma points
    Oct 21, 2020 @ 09:48
    Claushingebjerg
    0

    render block list recursively

    How do i render a block list recursively.

    For example i'm using a block list in my footer, which is want to render on all pages...

    @Html.GetBlockListHtml(Model, "sidefod", fallback: Fallback.ToAncestors)   
    

    Doesn't work

  • Claushingebjerg 900 posts 2449 karma points
    Oct 22, 2020 @ 09:24
    Claushingebjerg
    100

    Do it like this my friend:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        Layout = null;
        var node = Model.AncestorOrSelf();
    }
    
    <div>@Html.GetBlockListHtml(node, "footer") </div>
    

    That should work, but doesnt in my case, so i did:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        Layout = null;
        var rootnode = Model.Root();
    }
    
    <div>@Html.GetBlockListHtml(rootnode, "footer") </div>
    
  • Claushingebjerg 900 posts 2449 karma points
    Oct 22, 2020 @ 09:25
    Claushingebjerg
    1

    Wow, thanks H5YR!

  • Marc Goodson 1601 posts 10654 karma points MVP 6x c-trib
    Oct 22, 2020 @ 10:13
    Marc Goodson
    1

    He's very good that @Claushingebjerg - you should buy him a beer if you get the chance!

  • Claushingebjerg 900 posts 2449 karma points
    Oct 22, 2020 @ 11:06
    Claushingebjerg
    0

    I think i will... Today! :)

  • Amir Khan 1261 posts 2672 karma points
    Oct 22, 2020 @ 14:42
    Amir Khan
    0

    Glad you got it working, but can't you just do it like with any other property?

    Html.GetBlockListHtml(node, "footer", recurse:true)
    
  • Claushingebjerg 900 posts 2449 karma points
    14 days ago
    Claushingebjerg
    0

    Dont think so:

    "The best overload for 'GetBlockListHtml' does not have a parameter named 'recurse'"

Please Sign in or register to post replies

Write your reply to:

Draft