简体   繁体   English

面包屑未显示在Umbraco网站中

[英]Breadcrumb not showing in Umbraco Site

I created a partial view macro file in my umbraco backoffice for a breadcrumb. 我在umbraco后台中为面包屑创建了部分视图宏文件。 I inserted the macro to my masterPage and ran the site, but I couldn't see anthing. 我将宏插入到masterPage中并运行了该站点,但看不到任何东西。 No breadcrumb navigation, no errors, jsut nothing. 没有面包屑导航,没有错误,没有什么。 What could be wrong? 有什么事吗

Please see the breadcrumb code below 请参阅下面的面包屑代码

@inherits Umbraco.Web.Macros.PartialViewMacroPage

@*
    This snippet makes a breadcrumb of parents using an unordered html list.

    How it works:
    - It uses the Ancestors() method to get all parents and then generates links so the visitor can go back
    - Finally it outputs the name of the current page (without a link)
*@

@{ var selection = CurrentPage.Ancestors(); }

@if (selection.Any())
{
    <ul class="breadcrumb">
        @* For each page in the ancestors collection which have been ordered by Level (so we start with the highest top node first) *@
        @foreach (var item in selection.OrderBy("Level"))
        {
            <li><a href="@item.Url">@item.Name</a> <span class="divider">/</span></li>
        }

        @* Display the current page as the last item in the list *@
        <li class="active">@CurrentPage.Name</li>
    </ul>
}

Please Help me out. 请帮帮我。 Thanks. 谢谢。

so below is my standard breadcrumb code i use, this is in a partial view that sits on the master page 所以下面是我使用的标准面包屑代码,这是在母版页上的部分视图中

    @inherits UmbracoTemplatePage
@{
    var selection = Model.Content.Ancestors().ToList();
    if (selection.Any())
        {
        var currentPageTitle = Model.Content.Name;
        <ul class="breadcrumb">
            @foreach (var item in selection.OrderBy("Level"))
                {
                var pageTitle = item.Name;
                <li>
                    <a href="@item.Url" title="@pageTitle">
                        @pageTitle
                    </a>
                </li>
                }
            <li class="active">
                @currentPageTitle
            </li>
        </ul>
        }
}

As i mentioned to you before this will only show on pages under the home page see example image of my content tree below. 正如我之前向您提到的那样,这只会显示在主页下的页面上,请参阅下面内容树的示例图像。

umbraco内容树

All pages from about going down and under any of them will show the bread crumb and home page wont (because it doesn't have any ancestors ie its the first page in the tree). 上下左右的所有页面都将显示面包屑,并且主页将不会显示(因为它没有任何祖先,即它在树中的第一页)。

I got a feeling you content tree is not nested like the one above ie all pages are on the same level as the home page, can you please add a picture of what your content tree looks like. 我感觉到您的内容树没有像上面那样嵌套,即所有页面都与主页处于同一级别,请您添加一张内容树的图片。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM