Skip to content

Instantly share code, notes, and snippets.

@bobdobbalina
Created May 15, 2018 18:42
Show Gist options
  • Save bobdobbalina/8b5b389f1e7d3341c283e797aee63069 to your computer and use it in GitHub Desktop.
Save bobdobbalina/8b5b389f1e7d3341c283e797aee63069 to your computer and use it in GitHub Desktop.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var homePage = Model.Content.Site();
}
@helper RenderChildPages(IEnumerable<IPublishedContent> pages)
{
if (pages.Any())
{
<ul>
@foreach (var page in pages.Where("Visible"))
{
if (!(page.HasProperty("excludeFromSitemap") && (bool)page.GetPropertyValue("excludeFromSitemap")))
{
<li>
<a href="@page.Url">@page.Name</a>
@{
var childPages = page.Children.Where("Visible");
@RenderChildPages(childPages)
}
</li>
}
}
</ul>
}
}
<nav class="sitemap-nav">
<ul>
@if (homePage.Children.Where("Visible").Any())
{
var childPages = homePage.Children.Where("Visible");
<ul>
<li class="home">
<a href="/">@homePage.Name</a>
@RenderChildPages(childPages)
</li>
</ul>
}
</ul>
</nav>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment