Keeping parent and sub level navigation highlighted
Hi everyone:) I wonder if someone could help by either tweaking my code, or just by explaining how I can do this and then I'll go away and (ahem ...try) to sort the code out, and repost the result if it's successful. I use the following for my navigation:
... this works just fine for my purposes, top level items have <li class="current"> when selected, sub level has <li class="parent"> when sub page is selected. This is good for me as my site only goes as far as:
www.mysite.com/page/sub-page.aspx
However, if I go any deeper I lose the current (or parent) highlighting. Problem is I don't fully understand the code (any explanation would be fantastic ie what's the difference between $currentPage/@id and current()/@id ??). I have studied the umbraco tutorial on xpath but still a little confused.
Thanks in advance if someone can shed some light on this. Thanks :)
Hey instead of using a for loop to iterate through all the children you could use a recursvily called template and then pass in a parameter to tell it that the node is a child of the active node.
something like this should work, start with the first node, i.e. this might be your home page.
I havn't tested this but I think this or somethign like it should technically work. The basic idea of keeping trackof whether or not the parent is the current/active page by passing a variable through a recursive tempalte should be okay.
Does anyone have a better way? Is there a way of testing if a node is in a node set? I.e. testing if a node is a child of another node.
I really couldn't tell you if your version is a good solution or not, I haven't got as far as params and calling templates in macros yet, still learning :)
Keeping parent and sub level navigation highlighted
Hi everyone:) I wonder if someone could help by either tweaking my code, or just by explaining how I can do this and then I'll go away and (ahem ...try) to sort the code out, and repost the result if it's successful. I use the following for my navigation:
... this works just fine for my purposes, top level items have <li class="current"> when selected, sub level has <li class="parent"> when sub page is selected. This is good for me as my site only goes as far as:
www.mysite.com/page/sub-page.aspx
However, if I go any deeper I lose the current (or parent) highlighting. Problem is I don't fully understand the code (any explanation would be fantastic ie what's the difference between $currentPage/@id and current()/@id ??). I have studied the umbraco tutorial on xpath but still a little confused.
Thanks in advance if someone can shed some light on this. Thanks :)
Hey instead of using a for loop to iterate through all the children you could use a recursvily called template and then pass in a parameter to tell it that the node is a child of the active node.
something like this should work, start with the first node, i.e. this might be your home page.
Then the template would look like:
I havn't tested this but I think this or somethign like it should technically work. The basic idea of keeping trackof whether or not the parent is the current/active page by passing a variable through a recursive tempalte should be okay.
Does anyone have a better way? Is there a way of testing if a node is in a node set? I.e. testing if a node is a child of another node.
I really couldn't tell you if your version is a good solution or not, I haven't got as far as params and calling templates in macros yet, still learning :)
Thats cool,
Give the the above a go and see if it works. If it does then thats all good and perhaps somone with a better way will comment.
Thanks :)
is working on a reply...