Skip to content

Instantly share code, notes, and snippets.

@sleslie321
Created September 20, 2013 21:23
Show Gist options
  • Save sleslie321/6644129 to your computer and use it in GitHub Desktop.
Save sleslie321/6644129 to your computer and use it in GitHub Desktop.
Umbraco 6 Razor Nested Menu
@{ var SectionPage = CurrentPage.AncestorOrSelf(2);}
<h2><a href="@SectionPage.Url" title="@SectionPage.Name">@SectionPage.Name</a></h2>
<ul class="nav">
@foreach( var page in SectionPage.Children.Where("Visible"))
{
<li>
<a href="@page.Url" class="@(page.Id == CurrentPage.Id ? "selected":null)" title="@page.Name">@page.Name</a>
</li>
if ((page.Children.Count() > 0) && (page.IsAncestorOrSelf(CurrentPage)))
{
<ul>
@foreach( var page1 in page.Children.Where("Visible"))
{
<li>
<a href="@page1.Url" class="@(page1.Id == CurrentPage.Id ? "selected":null)" title="@page1.Name">@page1.Name</a>
</li>
if ((page1.Children.Count() > 0) && (page1.IsAncestorOrSelf(CurrentPage)))
{
<ul>
@foreach( var page2 in page1.Children.Where("Visible"))
{
<li>
<a href="@page2.Url" class="@(page2.Id == CurrentPage.Id ? "selected":null)" title="@page2.Name">@page2.Name</a>
</li>
}
</ul>
}
}
</ul>
}
}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment