Highlight Parent of selected item in dropdown menu
Hi
I am developing my first site using Contao and have a question regarding multi-level navigation.
The menu I have is working perfectly and renders the following html:
Code:
<ul id="mainDropDown" class="level_1">[*]<a class="first" blah...>wibble</a>[*]<a class="submenu" blah...>wibble
<ul class="level_2">[*]<a class="first" blah...>wibble</a>[*]<a blah...>wibble</a>[*]<a class="last" blah...>wibble</a>[/list][/list]
My 'nav_default_mod.tpl' is set to:
And the 'active' class gets set when choosing a child element from the '[*]<a class="submenu" blah...>wibble' parent.
What I would like to do is also add the 'active' class to the '[*]<a class="submenu" blah...>wibble' parent as well as the child so I can see from the level_1 which which menu contains the currently selected child.
I hope that makes sense.
Also, if in reading this you can answer another related question:
How can I create a parent item that doesn't have a page associates with it so that it simply forms an unlinked main menu entry?
Thanks for your time
Re: Highlight Parent of selected item in dropdown menu
Hi redwax
1) You don't need to change anything in the template at all. The current navigation link gets the class "active" and all its parents get "trail" ;) Use Firebug! :)
2) Just add a page and forward it to another content. Or what would you like to do with an unlinked navigation entry?
Re: Highlight Parent of selected item in dropdown menu
Quote:
1) You don't need to change anything in the template at all. The current navigation link gets the class "active" and all its parents get "trail" ;) Use Firebug! :)?
I feel like an idiot - I do use firebug but some how I completely missed that. Thank you.
Quote:
2) Just add a page and forward it to another content. Or what would you like to do with an unlinked navigation entry?
Simply, for level_1 menu entries that have a dropdown with level_2 child menu entries, I would like the level_1 to simply be a menu header, not a link to a page in itselft, so it becomes unclickable. Does this make sense? I'm not sure I have described myself overly well.
Thanks again for your time in assisting me.
Re: Highlight Parent of selected item in dropdown menu
Hmm, yes it does but I can't come up with a solution for you right now.
Maybe there is someone else who can help you out :)
Re: Highlight Parent of selected item in dropdown menu
redwax,
I just tried this and it seems to work. From the default nav_default.tpl, you just need to add an "or" statement in line 3, so it will read "if the nav item is active or has child menus, then don't link it and wrap in a span".
Just replace line 3 with this:
Code:
<?php if (($item['isActive']) || ($item['subitems'])): ?>
The full template will then look like this:
Re: Highlight Parent of selected item in dropdown menu
Take a look at www.contao-factory.com. We auto expand the menu trail and accordion the rest with a mouse over.
Re: Highlight Parent of selected item in dropdown menu
Quote:
Originally Posted by thyon
Unfortunately, this doesn't show anything at the moment. What I am left with tryiong to do is create a parent item that doesn't have a page associates with it so that it simply forms an unlinked main menu entry with child entries that are links?
Is there a reference somewhere of all the variables available. For instance, in the unrelated code...
Code:
if (($item['isActive']) || ($item['subitems'])
...there is mention of 'isActive' and 'subitems'. Is there a list somewhere of all the available $item['blah'] etc. I'm sure I had seen something once upon a time.
Thank you.