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:
My 'nav_default_mod.tpl' is set to: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]
Code:<ul <?php if ($this->level=="level_1"): ?>id="mainDropDown"<?php endif; ?> class="<?php echo $this->level; ?>"> <?php foreach ($this->items as $item): ?> <?php if ($item['isActive']): ?> <li class="active<?php if ($item['class']): ?> <?php echo $item['class']; ?><?php endif; ?>"> <span class="active<?php if ($item['class']): ?> <?php echo $item['class']; ?><?php endif; ?>"><?php echo $item['link']; ?></span><?php echo $item['subitems']; ?> <?php else: ?> <li<?php if ($item['class']): ?> class="<?php if ($this->level=="level_1"): ?><?php echo 'trigger'; ?><?php endif; ?> <?php if ($this->level=="level_2"): ?><?php echo $item['class']; ?><?php endif; ?>" <?php endif; ?>>"<?php if ($item['class']): ?> class="<?php echo $item['class']; ?>"<?php endif; ?><?php if ($item['accesskey'] != ''): ?> accesskey="<?php echo $item['accesskey']; ?>"<?php endif; ?><?php if ($item['tabindex']): ?> tabindex="<?php echo $item['tabindex']; ?>"<?php endif; ?><?php if ($item['nofollow']): ?> rel="nofollow"<?php endif; ?><?php echo $item['target']; ?>><?php echo $item['link']; ?> <?php echo $item['subitems']; ?> <?php endif; ?> <?php endforeach; ?>[/list]
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
Bookmarks