Top Level Outputs Top Level in Umbraco Razor Navigation
I'm struggling with very simple Umbraco 7 navigation. Basically, I have multiple "sites" in the same solution - or on the same site, but for different countries and languages. Their home page is top level nodes, and all subpages are nested at level 2 and below.
This is great for standalone sites (outputting level 1 node children). However, I want to create a second menu that only displays the top level nodes where I can switch between different sites. For some reason I am unable to do this.
@inherits UmbracoTemplatePage
@{
var homePage = CurrentPage.AncestorsOrSelf(1).First();
var subItems = homePage.Children;
var rootItems = homePage.Siblings;
}
<ul>
@foreach (var item in subItems) {
<li>@item.Name</li>
}
</ul>
<ul>
@foreach (var item in rootItems) {
<li>@item.Name</li>
}
</ul>
It outputs the first list fine, but the second list has no output. If I try to output @homePage.Name
it gives me output so I know the root items are available.
Ideally, I want it to output all root nodes in the second navigation (mostly SiblinbsOrSelf()
).
What am I doing wrong?
source to share