Copied to clipboard

Flag this post as spam?

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


  • Andreas Kaltenhuber 107 posts 286 karma points
    Feb 28, 2017 @ 13:00
    Andreas Kaltenhuber
    0

    role-based navigation - slows down rendering

    Hi,

    whats the best way to render a role based navigation?

    There is a function Umbraco.MemberHasAccess(string path) that should handle this.

    eg:

    foreach (var node in Model.Content.Children)
    {
        if (!Umbraco.MemberHasAccess(node.Path))
        {
            continue;
        }
        //member has access, generate menu here
    }
    

    But this function slows down the rendering as it does lots of duplicate roundtrips.

    Thx in advance,

    Andreas

    Umbraco 7.5.10

  • David Peck 690 posts 1896 karma points c-trib
    Mar 07, 2017 @ 13:25
    David Peck
    0

    I'd look in to Donut caching, where you 'vary by custom string' such that the string represents the User's role or Id.

    Alternatively, just create a decent view model for all the site pages that might be rendered and cache that model. The don't worry about the view running each time as it should be relatively fast. I don't think Umbraco.MemberHasAccess will hit the database.

Please Sign in or register to post replies

Write your reply to:

Draft