Skip to content

Instantly share code, notes, and snippets.

@sebastiandammark
Created April 11, 2017 13:06
Show Gist options
  • Save sebastiandammark/eee8b579b726cfaa3a2bec04d5b32984 to your computer and use it in GitHub Desktop.
Save sebastiandammark/eee8b579b726cfaa3a2bec04d5b32984 to your computer and use it in GitHub Desktop.
Model.Content.AncestorsOrSelf
@using Umbraco.Web.PublishedContentModels
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@{
var rootPage = Model.Content.AncestorsOrSelf<memberWebsite>;
var children = rootPage.Content.Children.Where("Visible");
<ul>
@foreach(var item in children){
<li>
<a href="@item.Url">@item.Name</a>
</li>
}
</ul>
}
@if (children.Any())
{
<ul>
@foreach (var item in children)
{
<li>
<a href="@item.Url">@item.Name</a>
</li>
}
</ul>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment