Search code examples
umbracoumbraco6

Getting children of a page by name


I'm trying to do something I thought was obvious, but I can't find a doc on this to save my life.. Basically, I want to build a list of links for all children of a page by it's name.. I'm trying this with no luck.. Is there an easy way to accomplish this?

@foreach (var page in Model.Content.Where(page => page.Name.Equals("About")).Children) { 
   <a href="">...</a>
}

Solution

  • If you mean you want links to the current page's children who are named "About" then you can do:

    @foreach(var page in @Model.Content.Children.Where(x => x.Name == "About"))
    {
        <a href="@page.Url">@page.Name</a>
    }