Hopefully somebody can help me with this. I've set up secondary menus below some of my parent (primary) menu items, and I'd like for the primary menu item to remain active while choosing among the various secondary menu items it contains.
In other words, I've got a menu item and it glows green when active. If I choose a secondary menu item below it, I'd like the parent to remain active (glow green).
The reason I'd like to fix this is because the target of a parent menu link is often the same target as one of my secondary links, too; so by clicking the parent menu, it glows, and the first choice within the secondary menu glows, too. However, when you click the second choice from the secondary menu, that choice will then glow, but the parent item goes back to an inactive state. The whole navigation concept is then lost, because the user won't know what category of links the secondary menu list belongs to (from the list of parent menus above).
Sorry if this is confusing.
For an example, you can check out my site.
Thanks in advance for any help!
Comments
css
Use css.
The 'active' class is there for precisely this reason.
I think the bit you are talking about is your
#secondary a.active {(the exact link is active)
If instead you were using something like
#secondary .active a {(the branch is active)
the highlighting would continue to happen as expected.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Thank you
I followed your advice, and changed #primary from a.active {...} to .active a {...}. Works like a charm. Thanks a lot for your help. The menu works exactly like I hoped.
Does not work for me for
Does not work for me for some reason... I am on Drupal 6.9 if this is important.
Any suggestions?
Please view-source on the
Please view-source on the themed page you are using. there may be a different class name there - like class="in-active-trail" or something. It's up to you to look at your own code - if you can't post a link to an example.
.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |
.dan. is the New Zealand Drupal Developer working on Government Web Standards
CSS source
The site is still offline only, so I post its CSS here:
I mean on your menu
I mean on your menu html.
.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |
.dan. is the New Zealand Drupal Developer working on Government Web Standards
PHP code
Here it is:
No :-) That's PHP
No :-)
That's PHP code.
View-source on the page showing the problem menu.
Copy the block of HTML that renders the menu (not the whole page please). In there we will see the actual class structure where there MAY be some semantic classnames you can build a CSS selector out of.
.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |
.dan. is the New Zealand Drupal Developer working on Government Web Standards
AFAIK there isn't. At least
AFAIK there isn't. At least not in D5.
The menu_trails module does what you want IIRC.
HTML code
Forgive my ignorance :-)
really?
See, that's not good.
Here's my example from a nonsense/dummy/dev site today.
In this case 'Enquiries' is a child item of 'dummy about item'.
Looking at the classes available to me there, I can theme
and also
If I want. This will show the currently active parent in red.
I'm not sure what theme (in D6) you are using if this is not working.
You did copy that menu code from a page where you expected the effect to work, didn't you? A page under another page that you wanted the menu to be highlighted in?
.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Some success finally
Actually I have written all the code from scratch. Used snippets from the book "Drupal 6 themes" by Packt.
Your advice works! It is interesting to mention that for some reason I can change property for background-color (as in your example) but not for the text color... Should it be like that?
At last below is the code you expect by me (without last modifications applied)... the previous one was without the children selected. Sorry for wasting your time man...
So it matches your example I think.
finally.
Fine, fine.
So you can see that
.active-trailis themable. Go for it!The text color will not take simple
colorsettings because it's a link. and your stylesheet or browser is probably coloring it with thea,a:linkora:visitedcolor instead, as that's stronger in the cascade specificity calculations.You may need
to really make it work. But that's just normal CSS.
.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Thank you
Thank you for all your help and time Dan! I owe you many beers :-)
The styling works with the "!important" declaration, I am not very into the CSS, so it is fine with me so far.