Loogin for a true Submenu Block
Hello Forum.
I'd like to create Block that simply displays a submenu. A submenu is a part of the main menu (primary links) that just does not start at level 0. A Submenu should be defined by it's Parent Node.
Example Structure:
N:1 Home
|-- N:2 Category A
| \-- N:4 Subcat A-1
| \-- N:5 Subcat A-2
| \-- N:6 Subcat A-3
\-- N:3 Category BIf I want to create a Submenu that consists of Subcat A-1 to Subcat A-3, this could be ideally done by:
<?php
$menu = mot_create_submenu($node=2);
?>The Resulting Menu is quite Flat:
* Subcat A-1
* Subcat A-2
* Subcat A-3According to some Tests and some documentation I read, such a Menu can be made with the Submenu Tree Module. Anyway, this module has many shortcommings sothat this does not solve my needs.
Consider another Example:
<?php
$menu = mot_create_submenu($node=1);
?>This Time the Submenu should be more complex:
* Subcat A
* Subcat BWhile being on the Homepage or any other page that is not a children of $node=1. Being on the Page Subcat A should then open the Menu like this:
* Subcat A
* Subcat A-1
* Subcat A-2
* Subcat A-3
* Subcat BDoes anyone know of the API Functions in Drupal 6 to create a Menu based on a Node value? Or knows of a module that already does the stuff describben above?

http://drupal.org/project/nic
http://drupal.org/project/nice_menus does this with a module and there are several themes that have it built-in (four seasons, framework, and the rooplethemes come to mind).
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
-<>-
I found that one as well but I thought this works with dynamic open/close stuff what I strongly dislike. I take a look If I find a way to tweak it, thanks so far!
Take a look at the four
Take a look at the four seasons and framework themes-- I believe they are closer to what you want (secondary menus stay open).
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
\/\/\/
Well, I just wonder that such a simple thing does not exist. Could be named Menu Block, Submenu Block or similar.
Well, the good thing is that all this Stuff is open source. Sometimes it's faster to take a look into the sourcecode then to surf the huge drupal site to find out how things are done.
I was able to hack the nice menu module sothat it displays the menu inside a block just the standard way, without any scripts and nice-menu only themed output.
anyway, the menu stays open alls the time. this is not exactly what I want again, I just want that it displays it's own level 1 all the time as long as the current node is the submenu's root node or any other node that is not a children of the submenu.
if a node is a children of the submenu it has to open much enough sothat the entry for the current node and all this nodes direct childs are displayed.
I think it does exist and I
I think it does exist and I just found it-- -except there's no d6 version yet... check out http://drupal.org/project/slicedmenu
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
,.:,.:
Drupal 6 version is mandatory for me. I checked the API and all of the Drupal 5 Code does not work for that any longer. But I stick with the nice menu sourcecode and I'm making progress in understanding the menu things. Nice Menu come with any feature (including multiple, configureable blocks), the only downside is the unflexibility of nice menus to handle the output fine-grained. it is very limited to only have this kind of special menu. I know those are popular, but in my case not^^
~**~
Well, I now tested that thing. If there wouldn't be any *blink* *blink* and only standard menu output, this would be exactly what I need. The Module developers should provide a function to disable the jQuery part of it, even though I think they are mostly proud of it because they named it "nice". Well this is nice but not modular enough in my case.
I'll take a look if I can hack the source.
|<>|
Hacking the Menu:
I wonder what a mlid and a plid is. A page states that the plid is the parent's mlid. But what's a mlid then? These terms are used in the menu api a lot.
mlid stands for menu link id I assume. This function loads data from the database to gather that data.
menu_tree_all_data - used by nice menus but it returns all data and in-active-trail does not work then. such a pitty! A workaround might be using menu_tree_data but it needs another set of parameters.
bahh, sql inside. well this is getting too late for me... maybe I should check the standard menu blocks first how those a handling things.
heres a quick way to get a one level submenu block
$uri = $_SERVER['REQUEST_URI'];
$len = strlen($uri);
$uri = substr($uri, 1, $len-2); //strip slashes
$src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $uri));
if(!$src){ $src = $uri; }; //get node/id
$mlid = db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", $src)); //get menu id
if($mlid){
$sth = db_query("SELECT link_path FROM {menu_links} WHERE plid = %d", $mlid); //get children paths
while($result = db_result($sth)){
$r = substr($result, 5); //strip 'node/' from link_path
$title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", intval($r)));
//get node title
echo "<br><a href='/{$result}'>".
$title."</a><br>";
}
}