I currently have a repeater that I use to create our main site navigation(I have found it to be more flexible than using a default Kentico nav). It currently makes a collection of list items using the code
<li class="vs-menu-primary__item"> <a href="{% GetDocumentUrl() %}" class="{% if (IsCurrentDocument()) { return "sel" } else { return "" } #%}" title="{% HTMLEncode(DocumentName) %}">{% HTMLEncode(DocumentName) %}</a> </li>
This returns a navigation such as Home, Treat, Learn, About Us with the relevant item stylised if you are in that page (currently an underline. I now want to add that if I am in page under that set of navigation that I it should also show as selected. Such as
I didn't know if I should be able to add an else if (CurrentDocument.Parent.Parent()) {return "sel"}
else if (CurrentDocument.Parent.Parent()) {return "sel"}
to it but I cannot get the syntax to work. Any help appreciated.
Use just CurrentDocument.NodeAliasPath.StartsWith(NodeAliasPath)
Hi Alan,
Try to use this condition in IF statement:
(IsCurrentDocument() || CurrentDocument.Parent.NodeID == NodeID || CurrentDocument.Parent.Parent.NodeID == NodeID)
Where NodeID is a ID of current menu item.
Than you both for the answers, the answer from Jan was easier to implement. Thanks for the help.
Yeah, His solution is better:)
Please, sign in to be able to submit a new answer.