[drupal-devel] [feature] DHTML expandable menu links

brevity drupal-devel at drupal.org
Thu Sep 15 15:16:58 UTC 2005


Issue status update for 
http://drupal.org/node/5943
Post a follow up: 
http://drupal.org/project/comments/add/5943

 Project:      Drupal
-Version:      cvs
+Version:      4.6.3
 Component:    theme system
 Category:     feature requests
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  flevour
 Updated by:   brevity
-Status:       active
+Status:       patch (code needs review)
 Attachment:   http://drupal.org/files/issues/page.tpl.php.txt (5.14 KB)

Based on the bluemarine template [1] for the PHP template engine and
work by Nick [2] (example menu [3]), the following is a adaptation with
working dynamic menu:


page.tpl.php [4]


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.


-- Sorry for duplicate posting in http://drupal.org/node/31307.
[1] http://drupal.org/project/bluemarine
[2]
http://www.nickrigby.com/article/25/drop-down-menus-horizontal-style-pt-3
[3] http://www.nickrigby.com/examples/dropdown4/index.htm
[4] http://ten.ic24.net/drupal/page.tpl.php.txt




brevity



Previous comments:
------------------------------------------------------------------------

Thu, 19 Feb 2004 23:01:32 +0000 : flevour

I was wondering if anyone has already worked out a patch to allow menus
created by the menu() call to be dhtml-ly expandable.
Most of the times its a waste of bandwidth to load 2/3 different pages
to access the page you want.
Best regards,
flevour




------------------------------------------------------------------------

Fri, 20 Feb 2004 15:25:35 +0000 : flevour

Setting as feature request.




------------------------------------------------------------------------

Mon, 23 Feb 2004 04:11:02 +0000 : ax

i just implemented this [5] on my drupal site [6]. please have a look,
see if it works with your browser, and tell me what you think of it.
and feel free to make a patch for drupal (i won't have much time before
next weekend).
[5] http://drupal.kollm.org/node/view/36
[6] http://drupal.kollm.org/




------------------------------------------------------------------------

Mon, 23 Feb 2004 04:49:54 +0000 : moshe weitzman

Wonderful. This is an elegant, elegant implementation. I'd like to see
menu.inc patched as ax suggests (possibly add a param to the function)
so we can experiment with css menus.


i think the javascript error on ax's site happens when the nav block is
not shown. just an oversight i'm sure.




------------------------------------------------------------------------

Mon, 23 Feb 2004 13:59:27 +0000 : Anonymous

Works fine here on Firebird 0.7.




------------------------------------------------------------------------

Tue, 24 Feb 2004 07:39:29 +0000 : ax

thanks to everyone for testing.


> i think the javascript error on ax's site happens when the nav block
is not
> shown. just an oversight i'm sure.


right you are. i fixed that in the multimenu javascript [7].


regarding the half a second delay before the menu pops up, to save the
user from disortientation suggested at drupal.kollm.org [8]: i guess
this isn't possible with a pure css menu, but would require
considerably more javascript. which /i/ almost certainly won't find /
implement. feel free to suggest / implement anything related, though.


what i could imagine is to make the menu look more like a real menu as
on CSS Creator [9], ie. instead of expanding the submenus to the
bottom, shift them out to the left / right. as i said before, this
probably won't happen before the weekend.
[7] http://drupal.kollm.org/themes/ax_clean/multimenu.js
[8] http://drupal.kollm.org/node/view/36#comment
[9] http://www.csscreator.com/menu/multimenu.php#vertm




------------------------------------------------------------------------

Fri, 27 Feb 2004 02:45:45 +0000 : Anonymous

Indeed this would like nice with rollover menus like those on csscreator




------------------------------------------------------------------------

Sat, 13 Mar 2004 05:46:12 +0000 : moshe weitzman

Attachment: http://drupal.org/files/issues/menu_show_all_items.patch (927 bytes)

One line patch to menu_tree() so we can optionally show all links, not
just active links. This is all the core code that needs to change in
order to facilitate expandable menus.




------------------------------------------------------------------------

Sat, 13 Mar 2004 06:34:29 +0000 : gordon

I have written my own module to create a dhtml navigation tree, by
linking in phplayersmenu to build the tree menu and handle all the
cross browser capiblities. I did have to copy most of menu_tree() to do
this, but it meant that I didn't have to change the core.


But it was not just menu_tree that has to be changed. remember that
once you have made this change to useing dhtml menus you have access to
every menu. So modules like the watchdog only display it's menus when
you are in the admin section.


There really needs to be a method to say to all modules that we want
every menu, and done try to be a smart bugger.




------------------------------------------------------------------------

Thu, 18 Mar 2004 03:52:54 +0000 : moshe weitzman

Gordon makes a good point. I think this patch is worthy despite this
known limitation.




------------------------------------------------------------------------

Fri, 26 Mar 2004 06:40:49 +0000 : ax

i put an updated version [10], implementing real csscreator style
rollover menus and submenu indicators, on my site. please note the NOTE
at the end.
[10] http://drupal.kollm.org/node/view/38




------------------------------------------------------------------------

Fri, 26 Mar 2004 09:46:58 +0000 : adrian

Take a look at the following demo of the Archomai Transmenu drop down
menu. 


It uses javascript, yes.. but it degrades well .. and doesnt require
horribly kludged html


I have tried it on firefox 0.7, ie 6.0 and opera 7 with exactly the
same results.




------------------------------------------------------------------------

Fri, 26 Mar 2004 14:09:39 +0000 : ax

> Take a look at the following demo of the Archomai Transmenu drop down
> menu.


nice menu, nice theme. thats phptemplate [11], isn't it?


> It uses javascript, yes.. but it degrades well .. and doesnt require
> horribly kludged html


the nice thing about the CSS Creator menu [12] is that for non-IE
browsers, it works *without any javascript*, with css only. and the
javascript to make it work in IE is just some 10 lines. besides that,
it
degrades as well and doesn't require kludged html, neither.


i'm sure your demo can be done the same as nice with the CSS Creator
menu. mind to give it a try?


[11] http://drupal.org/node/view/6711
[12] http://www.csscreator.com/menu/multimenu.php




------------------------------------------------------------------------

Fri, 26 Mar 2004 14:33:49 +0000 : moshe weitzman

One more benefit of the CSSCreator scheme is that the HTML is much
easier to construct. The brief javascript snippet in CSSCreator figures
out which items have submenus and applies the proper styling
accordingly. The Anarchai menu on the other hand requires the user to
embed classes in his HTML depending on whether they have children or
not. Thats harder to contruct. An example from Adrian's site example,



<?php
 <li class="firstItem collapsed">capdev
?>






------------------------------------------------------------------------

Thu, 15 Apr 2004 19:30:18 +0000 : JonBob

When the admin-customizable menu patch is applied
(http://drupal.org/node/view/7172), this should be possible to do
without patching core. The whole menu tree will be available at all
times to modules.




------------------------------------------------------------------------

Sun, 18 Apr 2004 15:41:08 +0000 : Dries

Has anyone tried using expandable menus after JonBob's menu changes have
been committed?  According to JonBob this patch is no longer required
...




------------------------------------------------------------------------

Sat, 24 Apr 2004 15:54:14 +0000 : Dries

I'm marking this fixed as I believe this is no longer an issue now
JonBob's menu system improvements hit CVS.  Please reopen if necessary.




------------------------------------------------------------------------

Sat, 24 Apr 2004 16:02:17 +0000 : moshe weitzman

The new menu system makes this job possible, but still difficult.  I
think the patch proposed here is still a valid approach. What the UI
designer needs is for the menu system to output a UL. menu_get_menu()
does not do this. menu_get_tree() does, but it omits invisible items.
Thus, I still propose we enhance menu_get_tree() to optionally include
hidden items.




------------------------------------------------------------------------

Tue, 27 Jul 2004 14:17:45 +0000 : JonBob

In HEAD, theme('menu_tree', 1, TRUE) will return a rendered tree of all
accessible menu items in the main nav menu.




------------------------------------------------------------------------

Fri, 11 Feb 2005 15:19:11 +0000 : moshe weitzman

Perhaps some entrprising theme designer wants to apply some DHTML menu
renderer to theme('menu_tree', 1, TRUE), the function cited by JonBob.
The output of that function shoudl work with most smart menu scripts,
since its just a UL




------------------------------------------------------------------------

Fri, 15 Jul 2005 21:25:23 +0000 : lekei

Since this thread was before 4.6 -- is "head" referred to here 4.6 or
was all the work I did building a template with DHTML menus a waste?


I need to launch this site, do I need to remove the menus from the
template? I didn't think that an apparently closed feature request was
the right place to ask, but I go to response trying to ask in what I
thought was a more appropriate location.




------------------------------------------------------------------------

Thu, 11 Aug 2005 16:11:22 +0000 : ax

hm - seems that theme('menu_tree', 1, TRUE) doesn't work anymore?
apparently, it silently disappeared between revision 1.77 and 1.78 [13]
as part of this patch [14]. r1.78 was the penultimate change before
DRUPAL-4-6 [15], which means that theme('menu_tree', 1, TRUE) is /not/
in Drupal 4.6.


bad bad bad. i rely on this feature for a dynamic menu on certain sites
of mine. was the patch supposed to remove it ("Make local tasks more
themeable" doesn't suggest this)? is there another way to get an
completely expanded menu tree with proper menu item class labeling
("expanded", "collapsed") for the current menu path? if not, could this
functionality please be reinstated?


thanks for any insights.
[13]
http://cvs.drupal.org/viewcvs/drupal/drupal/includes/menu.inc?r1=1.77&r2=1.78
[14] http://drupal.org/node/17869
[15]
http://cvs.drupal.org/viewcvs/drupal/drupal/includes/menu.inc#rev1.79




------------------------------------------------------------------------

Fri, 09 Sep 2005 09:50:24 +0000 : lekei

So I take this to mean that Drupal can't do common DHTML menus, or any
menu structure other than the primitive
repaint-the-entire-page-on-each-mouse-click menus?


The only way to add items to a dynamic menu seems to be to hand-code
them into the template one page at a time.




------------------------------------------------------------------------

Fri, 09 Sep 2005 12:53:36 +0000 : brevity

Using menu_get_menu from http://drupaldocs.org/api/4.6/group/menu should
help to hand over a complete menu to some JavaScript, no? Something
along that lines in your phpTemplate/theme...


 <?php
 function my_menu_tree($pid = 1) {
 $menu = menu_get_menu();
 $output = ;
 {
   foreach ($menu['visible'][$pid]['children'] as $mid) {
       print theme_menu_item($mid); // print out current
menu-item; change to fit your dHtml/JS code?
       my_menu_tree($mid);  // recursive call to get
sub-menu-items
   }
 }
 return $output;
 }
 ?>


... combined with http://www.nickrigby.com/examples/dropdown4/index.htm
from
http://www.nickrigby.com/article/25/drop-down-menus-horizontal-style-pt-3
and I would be happy, too.




------------------------------------------------------------------------

Fri, 09 Sep 2005 15:38:55 +0000 : Tobias Maier

not        print theme_menu_item($mid); // print out current
menu-item; change to fit your dHtml/JS code?
better print theme('menu_item', $mid);


the function theme_menu_item is just the fall back function if no such
function is available in the theme!







More information about the drupal-devel mailing list