Hi all,

I'm looking for a Foldout Menu for Drupal 5.1. There are collapsible tree menus, but I have not been able to locate any menu module which supports foldout - horizontal foldout, that is. The only thing which, apparently, would come close, is "Nice_Menus", but from what I read, that module isn't really fully updated for 5.1, and I don't want to risk to completely mess up my site with unfinished modules.

The base menu would look like this:

People
Animals
Cars

When clicking on <i>Animals</i>, it would look something like this:

People
Animals    Cats
              Birds
              Dogs
              Snakes
Cars

Clicking on <i>Dogs</i>, would lead to:

People
Animals   Cats
             Birds
             Dogs    Poodles
                       Bassets
                       Spaniels
                       Chihuahua
             Snakes
Cars

I don't know if this way of typing will hold out once this item is saved, but I hope you understand what I'm looking for. Any ideas, anyone?

Ludo

Comments

modul’s picture

OK, I'll retype it:

The base menu would look like this:

People
Animals
Cars

When clicking on Animals, it would look something like this:

People
Animals -----Cats
-------------Birds
-------------Dogs
-------------Snakes
Cars

Clicking on Dogs, would lead to:

People
Animals -----Cats
-------------Birds
-------------Dogs -----Poodles
-----------------------Bassets
-----------------------Spaniels
-----------------------Chihuahua
Snakes
Cars

Oh well, something like this :-) I think you wizards are familiar with the concept of a foldout menu...

Ludo

sepeck’s picture

White space to html is single space. Use code tags to more preserve some things. I added them to your original post.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

Arundel’s picture

It's very easy to suggest that you look at UDM from Brothercake.
Rather than write a module, it's not difficult to implement this into a theme.
Cheers,
-A

modul’s picture

Hi Arundel,

Thanks for your pointer to UDM. You also write that it "is not difficult to implement this into a theme". Umm... I have been using Drupal for 2 (Two) days, and "implement this into a theme" sounds like something which I have not yet mastered At All.

- Could you give me a starting point? How to do that?
- And is it possible to use this UDM in the same way as the standard Drupal menu, i.e. are the urls "automatically" inserted through some backend click on the button, or would it have to be done manually for every menu item?

Ludo

vm’s picture

seems to me you may want to take a look at the dhtml_menu already available in the downloads area from Drupal 5.x

modul’s picture

Hi VeryMisunderstood,

I already took a look at Dhtml_menu, but that's not what I'm looking for. Dhtml_menu is meant for a collapsible tree, but I am looking for a Foldout menu.
- A collapsible tree essentially opens "downward". What is under the item clicked, moves down, to make space for the sub-items to be opened. That's not what I am after, because my menu is constrained to a rather narrow space (106px, orders of the boss, sorry...), which leaves only a very small space to 2nd or 3rd level items.
- A foldout menu, on the other hand, moves "sideways". When you click on something, the sublevel opens Next to the item clicked, not below it. These sublevels temporarily overlap the central pane, but disappear as soon as you click on a sublevel item (or at least, that is what I would like the menu to do...).

The UDM menu mentioned higher in this thread, appears to be doing exactly what I want, judging from the demo. But I have No Idea how to "simply put this into a theme", as the signaller wrote...

Ludo

hectorplus’s picture

There's the Admin module, the links folds out: http://drupal.org/project/adminblock
Check out the nice menu module, too. I know it works for 4.7, not sure if there's a version for D5.

Youfolder.com
Share what's in your folder for the Hispanic community in Canada.

modul’s picture

There is a 5.x version available, but from the instructions I gather it is meant to kind of separate the administration part from the rest of the menu. That could get me going, but I think it would be nicer to have menu which is "simply" general purpose, not just for the things reserved for the administrator.

Ludo

hectorplus’s picture

You could create a new menu, and select that new menu as your admin menu in the block settings for the admin menu module, but its not really the admin menu!

Youfolder.com
Share what's in your folder for the Hispanic community in Canada.

vm’s picture

to use UDM in the theme

you would have to copy the download files to your theme folder. Llooking at the template.php UDM provides. you will have to take

<link rel="stylesheet" type="text/css" href="/udm4-php/udm-resources/udm-style.php" media="screen, projection" /> and add that to the <head> of the page.tpl.php of your Drupal theme.

Thats all of the investigation I've done. How this would get incorporated into a menu block? I can't be positive at moment, will sit down with it later tonight. If you make progress feel free to report back. UDM's license states that for commerical sites, you would have to pay a fee. This may not be an avenue you want to travel down. Their copyright must be included in the code as well.

modul’s picture

Hi VeryMisunderstood,

I've been dabbling with this UDM a bit myself, but I haven't made much progress. Standalone, it works quite well, but I don't have a clue how to integrate the thing in a block - well, what 'd you expect after just 3 days of Drupal :-) .

I very much appreciate your tip, and if "later tonight" you come up with something, that would be fantastic. My "night is already later": it's 1:30 in Belgium, and I'm hitting the sack now. But I do hope with your invaluable help UDM can be told to work in a block...

Thanks again!

Ludo

mrf’s picture

I successfully implemented UDM on a Drupal site I did in 4.7. UDM requires you to apply both the class and id UDM to the ul of the menu you would like to use. To accomplish this I had to override theme_menu_tree and apply the classes, and then override theme_menu_item to strip out the class and ids from the submenus.

I now am trying to do the same thing, with the same piece of code, in Drupal 5, but for some reason the theme_menu_tree override is only applying to submenus and not to the top level of the menus which still have their default "menu" class.

My issue (and hopefully a solution soon!) can be seen in the following forum post. http://drupal.org/node/140654

modul’s picture

Thanks for your reply, MRF, but "override theme_menu_tree" sounds to me like the first line from that literary masterpiece How to make rain: "First, create a couple of clouds". I mean, I'm relatively new to Drupal, and I do still need very step-by-step and follow-the-guide instructions... So... :-)

Ludo

mrf’s picture

Overriding theme functions is confusing at first, but once you get your head around it, it will give you have much more control over your themes.

You can upload a file called template.php to the main folder of your theme (its already there for a lot of themes), and in this file you can tell Drupal to change the default way it spits out certain blocks of html.

In order to get UDM to work in 4.7 all I had to do was tell drupal to apply class="udm" and id="udm" to every menu tree instead of just applying class="menu" like it normally does. (unfortunately I don't have a clean solution for version 5 yet)

Here is the code that I used to accomplish this in 4.7. As a little bit of a disclaimer this overrides all menus, so your administration menus will lose their nice arrows, but will still be usable. The phptemplate_menu_item part of the code just strips out the udm class and id from the submenus, to make udm happy.

<?php
/********************************************/
function phptemplate_menu_tree($pid = 1) {
  if ($tree = menu_tree($pid)) {
    $output .= "<ul id=\"udm\" class=\"udm\">";
    $output .= $tree;
    $output .= "</ul>\n";
    return $output;
  }
}
/********************************************/
function phptemplate_menu_item($mid, $children = '', $leaf = TRUE) {
  $children = str_replace("<ul id=\"udm\" class=\"udm\">","<ul>",$children);
  return "\t<li id=\"item_".$mid."\">". menu_item_link($mid) . $children ."</li>\n";
 
}
?>

The theme developers handbook has an explanation of how theme overrides work here: http://drupal.org/node/55126

Nick Lewis has a much easier to understand (and more entertaining) explanation on his blog here: http://www.nicklewis.org/node/842

mrf’s picture

With the help of the Drupal community I've been able to track down my problem with applying the UDM classes in drupal 5.

When inserting the menu into your template make sure to use the following function:

theme('menu_tree', mid);