Copied to clipboard

Flag this post as spam?

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


  • Jonas Nilsson 137 posts 260 karma points
    May 14, 2014 @ 08:10
    Jonas Nilsson
    0

    HasAccess in navigation

    I'm trying to build a navigation for a structure with protected pages.

    Why can't i do this? (HasAccess is always null)
    @foreach (var page in root.Children.Where("Visible && HasAccess")
    Same if i make an condition like if(page.HasAccess()))

    But if i make an condition like if(library.HasAccess(page.Id, page.Path)) it will work.

    Would like to filter with HasAccess in the foreach to keep track of first and last node.

    Using Umbraco 7.1.1

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 14, 2014 @ 08:32
    Dennis Aaen
    0

    Hi Jonas,

    How about something like this:

    @foreach (var page in root.Children.Where("Visible == @0 && HasAccess == @1","False","True")

    You can find the documentation for Filtering, Ordering & Extensions in a .Where condition here, I know this documentation for DynamicNode but hope this can be a help even if you are using MVC.

    /Dennis

     

  • Jonas Nilsson 137 posts 260 karma points
    May 14, 2014 @ 10:25
    Jonas Nilsson
    0

    The problem is that the extension methods for HasAccess and IsProtected doesn't seem to work at all in 7.1.1.

    library.HasAccess(page.Id, page.Path) returns true or false, but if I use page.HasAccess() it returns null.

    /Jonas

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 14, 2014 @ 10:37
    Dennis Aaen
    0

    Hi Jonas,

    Have you tried something like:

    @Umbraco.HasAccess(page.Id, page.Path)

    In Umbraco 7 as far as I know the @Umbaco is replacing the old umbraco.library methods. Documentation can be found here under the first chapter.

    http://our.umbraco.org/documentation/Reference/Mvc/views

    Hope this helps,

    /Dennis

     

  • Kris Janssen 210 posts 569 karma points c-trib
    Jun 22, 2014 @ 12:10
    Kris Janssen
    0

    I think there is much confusion regarding this topic.

    It is a bit strange that something like Where("Visible && HasAccess") is not directly possible and that the helper is needed to check accessibility.

    I have posted a more elaborate question about it here.

Please Sign in or register to post replies

Write your reply to:

Draft