Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi everyone,
Am having some weird issues here in a sub nav where i need to display only the child of the current Node.
However its showing all the child nodes of the current page but under all of the other parent as well instead of the actual current node.
Can someone have a look at the code here.
<li><a @style @link>@i.Name</a> @if(i.ChildrenAsList.Where(x=>x.GetProperty("umbracoNaviHide").Value !="1" && x.NodeTypeAlias == "LLL" || x.NodeTypeAlias == "LC").Count()>0){ <ul class="sous-menu clearfix"> @foreach(dynamic node in i.ChildrenAsList){ <li class="@node.Name.Replace(" ", "-").ToLower()"><a href="@node.Url"> @node.Name</a> @if(CurrentModel.Children.Where(x=>x.GetProperty("umbracoNaviHide").Value !="1" && x.NodeTypeAlias == "LP").Count()>0){ foreach(var sub in CurrentModel.Children){ @sub.Name } </li> } </ul> }
Hi Fuji,
Obviously I don't know what "i" is from the snippet so I have assumed it's the current page, so give this a try:
@{ var i = CurrentModel; } @{ var myCollection = i.Children.Where(x => x.Visible && x.NodeTypeAlias == "LLL" && x.NodeTypeAlias == "LC"); if (myCollection.Any()) { <ul class="sous-menu clearfix"> @foreach (var node in myCollection) { <li class="@node.Name.Replace(" ", "-").ToLower()"><a href="@node.Url"> @node.Name</a> @{ var mySubCollection = node.Children.Where(x => x.Visible && x.NodeTypeAlias == "LP"); if (mySubCollection.Any()) { <ul> @foreach (var sub in node.Children) { <li>@sub.Name</li> } </ul> } } </li> } </ul> } }
Jeavon
Hi Jeavon,
That kind of weird i did remember deleting this threat cuz i kind of made a mistake myself on the navigation!.
Ah well, maybe you can find some useful bits in the above like x.Visible and .Any()
x.Visible
.Any()
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
CurrentModel not displaying Child of Current
Hi everyone,
Am having some weird issues here in a sub nav where i need to display only the child of the current Node.
However its showing all the child nodes of the current page but under all of the other parent as well instead of the actual current node.
Can someone have a look at the code here.
Hi Fuji,
Obviously I don't know what "i" is from the snippet so I have assumed it's the current page, so give this a try:
Jeavon
Hi Jeavon,
That kind of weird i did remember deleting this threat cuz i kind of made a mistake myself on the navigation!.
Ah well, maybe you can find some useful bits in the above like
x.Visible
and.Any()
is working on a reply...