Copied to clipboard

Flag this post as spam?

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


  • MB 273 posts 936 karma points
    Sep 01, 2016 @ 13:02
    MB
    0

    Check Node's Child-Child for property

    Hi everyone,

    I'm trying to check if a specific page's child's child has a property which is true or false.

    I currently have this code:

       var productSectionPage = Umbraco.TypedContent(1128);
       var productTypes = productSectionPage.Children(f => f.IsVisible() && f.DocumentTypeAlias == "categoryPage");
    
    • Page 1128 is Products
    • Inside 1128 there's a category
    • Inside category I'll like to check that node for a True/False value

    I just need to know, how I can go a step further in like this, if it was possible:

    productSectionPage.Children.Childre
    

    enter image description here

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Sep 01, 2016 @ 14:00
    Alex Skrypnyk
    100

    Hi Mike,

    You can do it like that:

    var item = productSectionPage.Descendants().Where(x => x.Name == "Racercykler");
    

    Be aware that Descendants method has poor performance, but its really helpful in situations like that.

    Also I used Name for determining needed node - it's bad also, better to use documentType alias or something like that.

    Thanks,

    Alex

  • MB 273 posts 936 karma points
    Sep 01, 2016 @ 19:44
    MB
    0

    Absolutely fabolous Alex! I changed it to documentType as it catches all the pages I need.

    Thank you SO very much for the help buddy! :D

Please Sign in or register to post replies

Write your reply to:

Draft