Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 936 posts 2571 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 936 posts 2571 karma points
    Oct 22, 2020 @ 09:24
    Claushingebjerg
    101

    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 936 posts 2571 karma points
    Oct 22, 2020 @ 09:25
    Claushingebjerg
    1

    Wow, thanks H5YR!

  • Marc Goodson 2141 posts 14344 karma points MVP 8x 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 936 posts 2571 karma points
    Oct 22, 2020 @ 11:06
    Claushingebjerg
    0

    I think i will... Today! :)

  • Amir Khan 1282 posts 2739 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 936 posts 2571 karma points
    Oct 12, 2021 @ 12:15
    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