[英]Breadcrumb not showing in Umbraco Site
我在umbraco后台中为面包屑创建了部分视图宏文件。 我将宏插入到masterPage中并运行了该站点,但看不到任何东西。 没有面包屑导航,没有错误,没有什么。 有什么事吗
请参阅下面的面包屑代码
@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>
}
请帮帮我。 谢谢。
所以下面是我使用的标准面包屑代码,这是在母版页上的部分视图中
@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>
}
}
正如我之前向您提到的那样,这只会显示在主页下的页面上,请参阅下面内容树的示例图像。
上下左右的所有页面都将显示面包屑,并且主页将不会显示(因为它没有任何祖先,即它在树中的第一页)。
我感觉到您的内容树没有像上面那样嵌套,即所有页面都与主页处于同一级别,请您添加一张内容树的图片。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.