My attempt at writing a dynamic navigation - help!
Hello,
My navigation/node structure is as follows:
Home
--About us
--Our Services
-----Finance
-----Insurance
My current code loops through the nodes and lists them in an unordered list. When the 'CurrentPage' has children, the menu includes the children.
The problem with this loop is that when one of those children (Finance or Insurance) is the 'CurrentPage', the 'if' condition on 'Our Services' node fails as the CurrentPage no longer has children, therefore 'Finance' and 'Insurance' no longer remain in the menu.
I want to add to my 'if', an '||' clause which would basically say 'or CurrentPage is a child node'. I'm aware of Model.Content.IsDescendant(), but not sure on how to use it.
I have tried to understand your structure, and where you want to display the children pages. If I have understand it correct correct you want to display child pages, when you are on a page that has children.
Try this code and see if it does what you need. if not, then don't hesitate to write again, and would try to help you.
My attempt at writing a dynamic navigation - help!
Hello,
My navigation/node structure is as follows:
Home
--About us
--Our Services
-----Finance
-----Insurance
My current code loops through the nodes and lists them in an unordered list. When the 'CurrentPage' has children, the menu includes the children.
The problem with this loop is that when one of those children (Finance or Insurance) is the 'CurrentPage', the 'if' condition on 'Our Services' node fails as the CurrentPage no longer has children, therefore 'Finance' and 'Insurance' no longer remain in the menu.
I want to add to my 'if', an '||' clause which would basically say 'or CurrentPage is a child node'. I'm aware of Model.Content.IsDescendant(), but not sure on how to use it.
Code below thanks
Hi Jason,
I have tried to understand your structure, and where you want to display the children pages. If I have understand it correct correct you want to display child pages, when you are on a page that has children.
Try this code and see if it does what you need. if not, then don't hesitate to write again, and would try to help you.
Hope this helps,
/Dennis
Hi Dennis,
Thanks for the suggestion, I inserted the code but it generates some interesting menu behaviour.
I have since found a solution. For anyone else struggling with a similar issue, code is below:
is working on a reply...