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 brevity on
Based on the bluemarine template for the PHP template engine and work by Nick (example menu), the following is a adaptation with working dynamic menu:
Change the line reading print my_menu_tree(24);
to your menu-id or to 0
to get a complete dynamic menu including administration menu items.
Comments
Thanks a lot! (allthough I
Thanks a lot! (allthough I haven't understood all the things that you made, it works fine for me).
I kept getting expanded menus
[revised]
This worked great for the main menu (my_menu_tree(0)), but the admin section had so many entries that it went off the bottom of the screen.
Now, I wanted the admin menu and the settings menu separately, just so I could see them. When I asked for the admin menu, I got expanded contents - each entry as its own menu, that spread out all over the place.
I am not familiar with the territory, but I hacked the my_menu_tree as shown below. I added a second command line variable, "firstcollapse". If I set the "firstcollapse" variable, everything comes out the way I want. The program prints the menu item, not its contents. I get a top menu, an admin menu, a settings menu, and nothing from within any of the above getting in the way. As far as I can tell, it behaves properly concerning permissions of the current user. The site where I applied it is in a sorry state of flux, but it is available (sometimes): recdivers dot com/drupal-4.6.3
Any comments on how to do this more smoothly or simply are welcome.
so here is the call and the code:
nice stuff
Cool stuff... I would just make the CSS into a seperate file... so it can be cached correctly... and save tonz of BW... I will hopefully hack on this very soon
code in page.tpl.php
Having the function in the page.tpl.php file is not a good idea. Put it in your template.php, assign the output to a variable and then print the variable in page.tpl.php file.
http://drupal.org/node/16383
Great code. I've implemented
Great code. I've implemented it like this to get a drop down admin menu at the top of the page, only if you have permission (otherwise it shows nothing). The menu consists of two top-levels, 'settings' and 'administer':
1. Move all of the admin menu to its own menu item.
2. Create new block, with the following in the body (replacing 63 with the ID of the admin menu) and input filter set to PHP:
3. The following in your style.css file for your theme (block-block-1 should be changed to the block number of your admin block):
4. Add the JavaScript mentioned in the post above to the head section of page.tpl.php:
(NOTE: is there somewhere else the JavaScript could go instead?)
5. Should work. Fingers crossed.
I've got this working in 4.7 HEAD.
I've made this code into a module
I've made this code into a module now, which seems to work really well :) You can find it here.
The module enables you to set how many (unlimited) independent dropdown menus you want, creating a new block for each one. You then set for each block the ID of the menu item to use for the menu's root.
Tested so far in IE6 and Firefox 1.5. Probably works in more browsers etc.
CSS still needs a lot of work. Currently just works for vertical dropdowns, but should work for horizontal too shortly. Let me know if anyone gets the module from me and whats to make some changes.