Copied to clipboard

Flag this post as spam?

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


  • Mark Evans 86 posts 116 karma points
    Sep 10, 2014 @ 15:54
    Mark Evans
    0

    chaining a statement

    im trying to get access to a specific folder (a hidden umbraco page) under any given page and within that folder get all the items of content...

    im trying this with no success, the page(folder) called "widgets" under home has 2 widget items under it but nothing is returned....

    var currentPage = @Model.Content;

    var widgets = currentPage.DescendantOrSelf().Children.Where(x => x.DocumentTypeAlias == "widgets").First().Children;

     

     

  • Dan Lister 416 posts 1974 karma points c-trib
    Sep 10, 2014 @ 16:02
    Dan Lister
    0

    Hi Mark,

    Try something like the following. I don't think you need the DescendantOrSelf() call on the current page as Children will return the current page's children.

    @{
        var widgets = Model.Content.Children.First(c => c.DocumentTypeAlias.Equals("widgets")).Children;
    }
    

    Thanks, Dan.

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Sep 10, 2014 @ 16:31
    Jeavon Leopold
    0

    If the page could be at a lower level than Children, then you could do this:

    var widgets = Model.Content.Descendants("widgets").First().Children;
    
Please Sign in or register to post replies

Write your reply to:

Draft