Copied to clipboard

Flag this post as spam?

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


  • TechRadiance 8 posts 99 karma points
    Jun 02, 2016 @ 20:14
    TechRadiance
    0

    Retrieve All Nodes

    I have the following data structure on my website:

    Homepage

    Smartphones

             >Reviews
    

    Laptops

            >Reviews
    

    I have reviews nested under the 'smartphones' and 'laptops' which are children of the homepage..

    I currently know how to get just the smartphone and laptop reviews seperately, but I want to be able to display both the smartphone and laptops together as one section, any advice how I can go about this?

    I've currently been using this:

    var node = new Node(1102).GetDescendantNodes();

    And then checking the nodeTypeAlias. However I've attempted to do this to pull all of the data, but it doesn't apepar to work :[

    Any help will be much appreciated thanks!

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Jun 03, 2016 @ 06:19
    Dennis Adolfi
    1

    Hi TechRadiance.

    Have i understood you correctly that you want to get all Review nodes no matter where they are located in your sites content-tree?

    @{
        var site = CurrentPage.Site();
        var allreviews = site.Descendants("review");
    }
    
  • Manish 373 posts 932 karma points
    Jun 03, 2016 @ 06:45
    Manish
    100

    Hi TechRadiance

    We can also get node by it's document type

    var nodes = uQuery.GetNodesByType("review");
    

    Thanks

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Jun 03, 2016 @ 06:53
    Dennis Adolfi
    1

    Just remember that uQuery is obsolete.

    Shannon Deminick wrote in https://our.umbraco.org/forum/developers/api-questions/45777-uQuery-vs-Examine-vs-IPublishedContent-for-Querying:

    uQuery and INode are essentially obsolete, you should be using IPublishedContent everywhere.

    However it works, just keep in consideration for future upgrades. I know they are loosing a lot of old code in Umbraco 8, so maybe uQuery disapears? Not sure.

  • Jordan 24 posts 182 karma points
    Jun 03, 2016 @ 08:42
    Jordan
    1

    Hi TechRadiance

    You can also use the umbraco Helper method to achieve this by grabbing all nodes by document type alias.

    @{    
        var allReviews = Umbraco.TypedContentAtXPath("//Review");    
    }
    

    This is given that the document type alias for the Review nodes is called Review.

  • TechRadiance 8 posts 99 karma points
    Jun 04, 2016 @ 09:26
    TechRadiance
    1

    Hi,

    Thank you for the replies, and your time replying to my question,

    I got this working with uQuery suggested by Manish,

    I will however look into the other methods suggested if It happens to become deprecated in later versions - @Dennis, thanks for pointing this out to me.

    Thanks again,

    Alex

  • 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