Skip to content

Instantly share code, notes, and snippets.

@carlosmartinezt
Created June 3, 2014 13:17
Show Gist options
  • Save carlosmartinezt/c0bddcd6c2704f67cdc8 to your computer and use it in GitHub Desktop.
Save carlosmartinezt/c0bddcd6c2704f67cdc8 to your computer and use it in GitHub Desktop.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var home = Model.Content.AncestorsOrSelf().First();
}
@helper Traverse(IPublishedContent node, int pad)
{
<li>
<a href="@node.Url">@(!String.IsNullOrWhiteSpace(node.GetPropertyValue<string>("pageName")) ? node.GetPropertyValue<string>("pageName") : !String.IsNullOrWhiteSpace(node.GetPropertyValue<string>("pageTitle")) ? node.GetPropertyValue<string>("pageTitle") : node.Name)</a>
@if (node.Children.Any(n => n.TemplateId > 0 ))
{
<ul class="disc">
@foreach (var n in node.Children.Where(n => n.TemplateId > 0 && !n.GetPropertyValue<bool>("hideFromSitemap")))
{
@Traverse(n, pad + 8)
}
</ul>
}
</li>
}
<ul class="disc">
@Traverse(home, 0)
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment