Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By ano1 on
Hi,
I have added a drupal menu to my site called Forum Navigation. I want to alter the html code for only this one menu so that the main
- can have a custom ID and CLASS (
- . How can I do this? I have searched the forums, and have tried the instructions here: but they seem to be only for secondary and primary links not other menus. Thanks in advance for the assistance.
Ano1
Comments
Opps error in question content
Hi,
It seem I forgot to but my code between < code >tags therefore it does not show up. Here is a re-post of my questions.
I have added a drupal menu to my site called Forum Navigation. I want to alter the html code for only this one menu so that the main
<ul>
can have a custom ID and CLASS (<ul class="demo" id="demo">
. How can I do this? I have searched the forums, and have tried the instructions here: but they seem to be only for secondary and primary links not other, custom, menus. Thanks in advance for the assistance.Ano1
Update help still needed
Hi,
After some more research I have located this snippet:
This outputs my menu. The menu gets outputted with classes like Leaf, expanded etc. However I would like this one menu to be output without these. I was debating a string replace, but was hoping for another solution using the API. Also I would need the 1st < u l > that was outputed to have a custom id and custom class and then all the rest of the ULs to be class and ID less.
Any suggestion of how to do this? If I was to do string replace how could I replace the only 1st < u l > class of menu with something else?
Thanks,
Ano1
Try this ...
I am not sure if this is the full answer, but I found this very helpful in what I think is a similar need:
http://webpodge.com/2007/02/28/drupal-tutorial-part-4-styling-an-individ...
Replace all instances of "#block-block" with "#block-menu" and it allows you to style individual menus.
Cheers.
Hello, i wanted to add a
Hello, i wanted to add a custom id "top" to the top level of the main menu in Drupal 7.
To do it, i added the following function hook in template.php
Basicaly i created a new global variable $GLOBALS['custom_variables']['main-menu'] that will let me know if i'm in the main-menu and if i'm it'll let me know at which level i'm. Generating specific HTML if i'm in the main menu on the top level.
is it neccessary to do a
is it neccessary to do a $GLOBAL ?
I think it is best if you check the &$variables first, it should contain all the $menu array generated by drupal.
cheers
--------------------------------------------------------------------------------------------------------
if you can use drupal why use others?
VicTheme.com
Well when i check the
Well when i check the $variables in mytheme_menu_tree($variables) it only contains the html of the current level i'm working on.
What i would like is to have access to an array that have all the information of my menu. I mean the higher level element their children and everyone links. That way i could just add the html myself. But i can't find how to do it and it's really bothersome as i've to integrate a rather complicated menu layout.
Not too sure if this is gonna
Not too sure if this is gonna work :)
by looking at theme_menu_tree function it calls for :
as you can see it only looks for the children ($variables['tree']['#children']) maybe if you override it to show the entire tree ($variables['tree']) it can show the whole tree?
--------------------------------------------------------------------------------------------------------
if you can use drupal why use others?
VicTheme.com
This doesn't work because all
This doesn't work because all i get is the rendered HTML.
I want to get the array and build my menu myself.
Need to add CSS and place link in separate column depending on their description etc...
Thanks for answering though.
I'm really starting to be late on this, so if anyone can help, please do.
doesn't seems working... have
doesn't seems working... have your tested it?
/** * Generate the HTML
I need a solution also,
I need a solution also, anyone found it?