Copied to clipboard

Flag this post as spam?

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


  • Zakhar 171 posts 397 karma points
    Jul 16, 2012 @ 15:24
    Zakhar
    0

    uQuery GetDescendantNodesByType() doesn't work as it should

    Hi guys,

    I have following structure of my content:

    Homepage

      Debates (doc type "Debates")

        Debate1 (doc type "Debate")

        Debate2 (doc type "Debate")

    So when I try to get nodes of type "Debate" from Homepage like this it doesn't work:

    List<Node> allDebates = node.GetDescendantNodesByType("Debate").ToList();

    But if I do it this way it works:

    Node debatesNode = node.GetChildNodesByType("Debates").FirstOrDefault();
    List<Node> allDebates = debatesNode.GetDescendantNodesByType("Debate").ToList();

    It looks like GetDescendantNodesByType() can only get direct children and works exactly like GetChildNodesByType().

    Is it a bug of uQuery, or am I doing something wrong?

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Jul 16, 2012 @ 15:31
    Lee Kelleher
    0

    Hi Zakhar,

    Just had a look at the source-code... think it might be a bug with that method (I'll need to test further to verify that though).

    As a workaround, you could try this:

    var allDebates = node.GetDescendantNodes().Where(x => x.NodeTypeAlias == "Debate");

    Cheers, Lee.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies