Copied to clipboard

Flag this post as spam?

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


  • Daniel Pazos 12 posts 123 karma points
    Oct 01, 2020 @ 13:58
    Daniel Pazos
    0

    Get nodes by documentType from different roots

    Hi,

    I want to query my web to get the name of all the nodes from a specific document type. My problem is that my tree is like this: enter image description here

    where the yellow root can be repeated N times.

    How can I get all my yellow roots to load the names of them in a navbar in my Index root?

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 01, 2020 @ 14:15
    Dave Woestenborghs
    0

    Hi Daniel,

    What version of Umbraco are you using. Are you using Modelsbuilder ?

    Dave

  • Daniel Pazos 12 posts 123 karma points
    Oct 01, 2020 @ 15:38
    Daniel Pazos
    0

    I am using Umbraco 8.6 without Modelsbuilder.

  • Daniel Pazos 12 posts 123 karma points
    Feb 28, 2021 @ 19:27
    Daniel Pazos
    100

    After several months I found a solution to my problem.

    The right way to get all nodes of the same type is with:

     var roots = Model.Root().Siblings().ToList()
    

    You can also filter your list to get the nodes with a specific alias:

    var roots= Model.Root().Siblings().Where(x => x.ContentType.Alias == "aliasToLookFor");
    
Please Sign in or register to post replies

Write your reply to:

Draft