Add WebCms
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@*
|
||||
This snippet makes a list of links of all visible pages of the site, as nested unordered html lists.
|
||||
|
||||
How it works:
|
||||
- It uses a custom Razor helper called Traverse() to select and display the markup and links.
|
||||
*@
|
||||
|
||||
@{ var selection = CurrentPage.Site(); }
|
||||
|
||||
<div class="sitemap">
|
||||
@* Render the sitemap by passing the root node to the traverse helper, below *@
|
||||
@Traverse(selection)
|
||||
</div>
|
||||
|
||||
|
||||
@* Helper method to travers through all descendants *@
|
||||
@helper Traverse(dynamic node)
|
||||
{
|
||||
@* Update the level to reflect how deep you want the sitemap to go *@
|
||||
var maxLevelForSitemap = 4;
|
||||
|
||||
@* Select visible children *@
|
||||
var selection = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);
|
||||
|
||||
@* If any items are returned, render a list *@
|
||||
if (selection.Any())
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in selection)
|
||||
{
|
||||
<li class="level-@item.Level">
|
||||
<a href="@item.Url">@item.Name</a>
|
||||
|
||||
@* Run the traverse helper again for any child pages *@
|
||||
@Traverse(item)
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user