Copied to clipboard

Flag this post as spam?

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


  • Ian Black 54 posts 230 karma points
    Nov 22, 2013 @ 13:31
    Ian Black
    0

    Using Descendants() in a UserControl

    Hi all,

    In a macro script I can use something like:

    var nodes = node.Descendants().Where("NodeTypeAlias == @0 || NodeTypeAlias == @1", "Article", "Discussion")
    

    This works perfectly and will return all descendants of those nodetypes.

    I'm now trying to recreate the same functionality inside a usercontrol but when I try I get the error: 'umbraco.NodeFactory.Node' does not contain a definition for 'Descendants'

    Can I only use Descendants inside a macro? It always seems there are completely different ways of doing things in macros, usercontrols etc. Is there a standard namespace that works across all of these?

    Thanks, Ian.

  • Comment author was deleted

    Nov 22, 2013 @ 13:33

    Yeah but that isn't part of the nodefactory look at using the dynamic objects instead

  • Ian Black 54 posts 230 karma points
    Nov 22, 2013 @ 14:53
    Ian Black
    0

    Thanks Tim.

    I've gotten as far as:

    DynamicNode root = new DynamicNode(1053);
    DynamicNodeList nodes = root.Descendants();
    

    But I can't construct my Where clause as I have done for my razor macro in the first post. Is there a different technique within usercontrols? If you could point me in the direction of some docs that would be greatly appreciated as so far I can't find what I'm looking for.

Please Sign in or register to post replies

Write your reply to:

Draft