Displaying parent nodes in Razor menu when no child nodes exist
Hey all,
I feel this is a simple task, however, I'm battling to get my head around this. I have a sub-menu which I'm converting from XSLT to Razor. The code simply lists any child nodes that exist under the parent.
What I'm trying to do is adjust the code so that when no child exists under a node the parent nodes persist so, in effect, the sub-menu doesn't disappear.
So basically the menu shows any child links that are available and visible until it can't find any more children, at this point the menu should show and persist a list of the children at its parent level - i.e. the menu doesn't just disappear off the screen.
Is there a more efficient way of writing the above? Like I say, it works but is it the best way?
Displaying parent nodes in Razor menu when no child nodes exist
Hey all,
I feel this is a simple task, however, I'm battling to get my head around this. I have a sub-menu which I'm converting from XSLT to Razor. The code simply lists any child nodes that exist under the parent.
What I'm trying to do is adjust the code so that when no child exists under a node the parent nodes persist so, in effect, the sub-menu doesn't disappear.
Could anyone provide any code pointers please?
Many thanks,
Mike
Hi Mike
Try doing something like
Is this what you are trying to achieve here ?
//fuji
Hi Fuji,
Yeah this is definitely along the right sort of lines. So this is what I've written. It works but I'm not sure it is the best way of writing it:
So basically the menu shows any child links that are available and visible until it can't find any more children, at this point the menu should show and persist a list of the children at its parent level - i.e. the menu doesn't just disappear off the screen.
Is there a more efficient way of writing the above? Like I say, it works but is it the best way?
Many thanks,
Mike
is working on a reply...