1
我試圖在前端網站上構建輔助導航,但我無法解決問題。在下面的代碼,輸出顯示了類似於:SPNavigation - 顯示用戶定義的導航
water -----water -----pollination -----dormancy pollination -----water -----pollination -----dormancy dormancy -----water -----pollination -----dormancy
// Loop through Root Webs in Site Collection
foreach (SPWeb TopLevelWebs in CurrentSite.AllWebs)
{
SPNavigationNodeCollection FirstLevelWebs = TopLevelWebs.Navigation.GlobalNodes[0].Children;
// Loop through each Child of Web
foreach (SPNavigationNode FirstLevelWebChild in FirstLevelWebs)
{
// Skip over pages and only look at webs (or "Area" as it is called in 'Properties')
if (FirstLevelWebChild.Properties["NodeType"].ToString() != "Page")
{
Response.Write(FirstLevelWebChild.Title + "<br />");
SPNavigationNodeCollection SecondLevelWebs = FirstLevelWebChild.Navigation.GlobalNodes[0].Children;
foreach (SPNavigationNode SecondLevelWebChild in SecondLevelWebs)
{
// Skip over pages and only look at webs (or "Area" as it is called in 'Properties')
if (SecondLevelWebChild.Properties["NodeType"].ToString() != "Page")
{
Response.Write("-----" + SecondLevelWebChild.Title + "<br />");
}
}
}
}
}
爲什麼上面沒有邏輯工作的頂層節點下的子網站?我還沒有完全理解「GlobalNodes」屬性,所以我必須假設問題出在哪裏。但我無法想出一個解決方案。
任何幫助將不勝感激。