umbraco
在任意页面获取根节点
var locale = CurrentPage.Site();
遍历根节点
@foreach (var module in CurrentPage.Site().Children) { if (module.DocumentTypeAlias.ToString() == "LinkFolder") { foreach (var linkModule in module.Children) { <li><span>| </span></li> <li><a href="#">@linkModule.linkText</a></li> } } }
获取当前节点 documentType (节点类型)
CurrentPage.DocumentTypeAlias;
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var locale = CurrentPage.Site(); var homeNode = locale.Descendants("Home").FirstOrDefault(); string breadcrumb= CurrentPage.DocumentTypeAlias; string breadcrumbHtml=string.Empty;//"<ul class='breadcrumb clearfix'><li><a href='/en-row/home/'>Home</a></li>";//string.Empty; switch (breadcrumb) { case "Home": break; case "CocktailsRecipe": breadcrumbHtml+="<li><span>></span></li> <li><a href='../'>"+CurrentPage.Parent.mobileNavigationName+"</a></li>"; breadcrumbHtml+="<li><span>></span></li> <li><a href='#'>"+CurrentPage.mobileNavigationName+"</a></li>"; break; case "ProductPage": breadcrumbHtml+="<li><span>></span></li> <li><a href='../'>"+CurrentPage.Parent.mobileNavigationName+"</a></li>"; breadcrumbHtml+="<li><span>></span></li> <li><a href='#'>"+CurrentPage.mobileNavigationName+"</a></li>"; break; default: breadcrumbHtml+="<li><span>></span></li> <li><a href='#'>"+CurrentPage.mobileNavigationName+"</a></li>"; break; } //breadcrumbHtml+= @Html.Raw(HttpUtility.HtmlDecode(Model.breadcrumbHtml)); } <div id="footer"> <ul class="breadcrumb clearfix"> @* <li><a href="/">Home</a></li> @Html.Raw(HttpUtility.HtmlDecode(breadcrumbHtml))*@ @if (CurrentPage.DocumentTypeAlias != "Home") { <li><a href="@homeNode.Url">@Html.Raw(HttpUtility.HtmlDecode(@homeNode.mobileNavigationName.ToString()))</a></li> <li><span>></span></li> } @for (int i = 2; i < CurrentPage.Level; i++) { <li><a href="@CurrentPage.AncestorOrSelf(i).Url">@Html.Raw(HttpUtility.HtmlDecode(@CurrentPage.AncestorOrSelf(i).mobileNavigationName.ToString()))</a></li> <li><span>></span></li> } <li><span>@Html.Raw(HttpUtility.HtmlDecode(@CurrentPage.mobileNavigationName.ToString()))</span></li> </ul> <ul class="policy"> <li><a href="/terms.html">TERMS & CONDITIONS</a></li> <li><span>| </span></li> <li><a href="/privacy.html">PRIVACY & COOKIES NOTICE</a></li> @foreach (var module in CurrentPage.Site().Children) { if (module.DocumentTypeAlias.ToString() == "LinkFolder") { foreach (var linkModule in module.Children) { <li><span>| </span></li> <li><a href="@linkModule.linkURL">@linkModule.linkText</a></li> } } } @* <li><span>| </span></li> <li><a href="#">DRINKIQ</a></li> <li><span>| </span></li> <li><a href="#">THEBAR.COM</a></li>*@ </ul> <p>© DIAGEO BRANDS B.V. 2015. ICP 10001616-9</p> </div>