Copied to clipboard

Flag this post as spam?

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


  • Sean Dooley 289 posts 528 karma points
    Jan 06, 2012 @ 14:15
    Sean Dooley
    0

    GetDescendantNodes(Func<Node, bool>)

    I am looking at using GetDescendantNodes(Func<Node, bool>) in a /base class but not sure to write for Func<Node, bool> to return nodes that a member has access to.

    Any ideas?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 06, 2012 @ 14:24
    Lee Kelleher
    0

    Hi Sean,

    You can use a lambda expression for the Func.  The params for the Func are the source and result, so for this you have an Node input (source) and the output needs to be a bool.

    Try something like this...

    var currentNode = umbraco.presentation.nodeFactory.Node.GetCurrent();
    var nodesMemberHasAccessTo = new System.Collections.Generic.List<int>() { 1111, 2222, 3333, 4444 };
    
    var nodes = currentNode.GetDescendantNodes(n => nodesMemberHasAccessTo.Contains(n.Id));

    Obviously I'm not sure how you are specifying the nodes that the member can have access to - hence using the generic list of ids.

    Cheers, Lee.

Please Sign in or register to post replies

Write your reply to:

Draft