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 Guys,
Can someone point out that am doing wrong here ? Am trying to display a css class depending on the nodeTypeAlias using Traverse for a navigation.
Here is my code snippet. Any suggestion please?
foreach(var list in companyList){ <div> <ul> <li><a href="#" class="@Library.If((list.AncestorsOrSelf("Company"))), "header", " ") @list.companyList">@list.Name</a> @traverse(list)</li> </ul> </div> }
You can use IsAncestorOrSelf to check whether a node is an ancestor of your current page like this:
foreach (dynamic page in pages) { <[email protected](page.IsAncestorOrSelf(Model), "class=\"selected\"")>@page.Name </li> }
I'm not quite sure what you are trying to check? What condition do you want the class to be headed?
Hi Dan,
Thanks for the response but this is not what am trying to achieve here. Under a folder content i have several pages and some has child nodes.
So the parent node lets say has a NodeTypeAlias(x) and its Child NodeTypeAlias(y). What i want to achieve here is get a UL list like this
<ul><li><a href="#" class="header">PageName</a> <ul> </li><a href="#" class="">SubPage Name </a></li> </ul></li></ul
i know who to get this using a typical foreach loop and checking if Children.Count() > 0, but i would like make use of traverse here, so whenever it gets the parent node with nodeTypeAlias(x) it shows header and if not then a blank class
Got it working, but somehow not the best solution using @helper traverse
<a href="#" class="@Library.If((list.NodeTypeAlias =="Company"), "header","") @list.companyList">@list.Name</a> @traverse(list)
//fuji
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Check Document Type when using traverse
Hi Guys,
Can someone point out that am doing wrong here ? Am trying to display a css class depending on the nodeTypeAlias using Traverse for a navigation.
Here is my code snippet. Any suggestion please?
You can use IsAncestorOrSelf to check whether a node is an ancestor of your current page like this:
I'm not quite sure what you are trying to check? What condition do you want the class to be headed?
Hi Dan,
Thanks for the response but this is not what am trying to achieve here. Under a folder content i have several pages and some has child nodes.
So the parent node lets say has a NodeTypeAlias(x) and its Child NodeTypeAlias(y). What i want to achieve here is get a UL list like this
i know who to get this using a typical foreach loop and checking if Children.Count() > 0, but i would like make use of traverse here, so whenever it gets the parent node with nodeTypeAlias(x) it shows header and if not then a blank class
Got it working, but somehow not the best solution using @helper traverse
//fuji
is working on a reply...