umbraco

 

在任意页面获取根节点

var locale = CurrentPage.Site();

遍历根节点

@foreach (var module in CurrentPage.Site().Children)
        {
            if (module.DocumentTypeAlias.ToString() == "LinkFolder")
            {
                foreach (var linkModule in module.Children)
                {
                    
  • |
  • "#">@linkModule.linkText
  • } } }
    View Code

    获取当前节点 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/'>Homea>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="/">Homea>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++)
          {
            ><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 & CONDITIONSa>li>
            <li><span>|  span>li>
            <li><a href="/privacy.html">PRIVACY & COOKIES NOTICEa>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.linkTexta>li>      
                    }
                }
            }  
    
    
           @* <li><span>|  span>li>
            <li><a href="#">DRINKIQa>li>
            <li><span>|  span>li>
            <li><a href="#">THEBAR.COMa>li>*@
          ul>
          <p>© DIAGEO BRANDS B.V. 2015. ICP 10001616-9p>
        div>
    View Code

     

    你可能感兴趣的:(umbraco)