Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 886 posts 2415 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 886 posts 2415 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(node, "footer") </div>
    
  • Claushingebjerg 886 posts 2415 karma points
    Oct 22, 2020 @ 09:25
    Claushingebjerg
    1

    Wow, thanks H5YR!

  • Marc Goodson 1451 posts 9716 karma points MVP 5x 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 886 posts 2415 karma points
    Oct 22, 2020 @ 11:06
    Claushingebjerg
    0

    I think i will... Today! :)

  • Amir Khan 1199 posts 2567 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)
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies