I remember something a long time teacher said, "Nick, if you make a suit out of a gorrilla, the arms are too long." I forgot why that was relevent to the topic of theming menu trees.
Moving on, here's a nice little function I wrote to return a themed menu tree by path.
<?php
// will return all menu items under "administration".
print theme('menu_tree_by_path','admin');
// will return links to all node submission forms
print theme('menu_tree_by_path','node/add');
// return the correct menu array by path
function menu_get_mid_by_path($path) {
// oddly, menu_get_item accepts a path, but returns the parent id.
$menu = menu_get_item(null, $path);
if (isset($menu['children'])) {
// so we have to extract the mid for theme_menu_tree from one of the child items
if ($pid = end($menu['children'])) {
$menu = menu_get_item($pid);
return $menu['pid'];
}
}
}
//theme the crap out of it
function theme_menu_tree_by_path($path) {
if ($mid = menu_get_mid_by_path($path)) {
return theme('menu_tree', $mid);
}
}
// throw a sexy party....
?>
Comments
Drupal 6...
I wish that returning an un-themed menu structure based on a path would be possible with the new menu system in D6... admin_menu needs your help!
Nice bit of code. I never
Nice bit of code. I never really comment my code as detail as that, may be I should start doing that. Thanks
Always comment on your code.
Always comment on your code. For yourself and for the others.
Nice!
Thanks for the tips :)
Nice tip.
The gorilla suit would fit me though. The girl who measured me for a tuxedo kept saying I had the longest arms she'd ever seen.
Hmm
Well that might be a "Good Thing". Long arms at a sexy party means you don't have to bend *completely* over to do up your shoelaces, if you get me.
True, but gorilla arms still
True, but gorilla arms still cause some pretty bad lower back issues.