到綁定導航我剛開始用一把umbraco 7, 工作,我創建了2個文件類型和3頁,一把umbraco如何使用asp.net mvc的
我使用我從入門工具包下載templeate。首先,爲什麼很難理解這個平臺?!?! 我看到了Umbraco.tv中的所有剪輯已經..
秒和重要的問題是: 爲什麼導航欄不顯示我所有的頁面?看來我只有1頁,這是很難已經編碼..
這裏是模板的代碼:
@inherits UmbracoTemplatePage
@{
// Model.Content is the current page that we're on AncestorsOrSelf is all of the ancestors this page has in the tree
// (1) means: go up to level 1 and stop looking for more ancestors when you get there First() gets the first ancestor found (the home page, on level 1)
var homePage = CurrentPage.AncestorsOrSelf(1).First();
var menuItems = homePage.Children.Where("UmbracoNaviHide == false");
}
<!-- Nav -->
<ul class="menu">
@* If the Url of the current page is "/" then we want to add the class "current_page_item" *@
@* Otherwise, we set the class to null, that way it will not even be added to the <li> element *@
<li class="@(CurrentPage.Url == "/" ? "sel" : null)">
<a href="/homepage">Home</a>
</li>
@foreach (var item in menuItems)
{
var childrenItems = item.Children.Where("UmbracoNaviHide == false");
<li class="@(CurrentPage.Id == item.Id ? "sel" : null)">
<a href="@item.Url">@item.Name</a>
@createSubmenu(childrenItems, item.Id)
</li>
}
</ul>
@helper createSubmenu(IEnumerable<IPublishedContent> nodes, int? parentId) {
if (nodes.Count() > 0){
<ul>
@foreach (var node in nodes)
{
var childrenItems = node.Children.Where("UmbracoNaviHide == false");
<li class="@(CurrentPage.Id == node.Id ? "sel" : null)">
<a href="@node.Url">@node.Name</a>
@createSubmenu(childrenItems, node.Id)
</li>
}
</ul>
}
}
<!-- /Nav -->
請嘗試像這樣 var menuItems = homePage.Children.Where(x.GetPropertyValue(「umbracoNaviHide」)==「1」);並使用.Where(x.GetPropertyValue(「umbracoNaviHide」)==「1」)修改代碼,在哪裏使用過.Where(「UmbracoNaviHide == false」)。 –