Posted by doublejosh on August 1, 2011 at 11:33pm
1 follower
Jump to:
| Project: | Jump |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Curious if it's possible to show certain level of menu hierarchy like Menu Block?
In my case I'd like to show a sub-section of the Primary Links when within a section. Meaning I'd like to select a parent and depth.
Comments
#1
I submitted this before I realized that it only showed the top level anyhow.
#2
Here's how I traversed the menu to create my block. But I'm still not sure how to use dummy items via the Jump API...
<?php
function CUSTOM_jump_menu($menu, $parent) {
// Load up the menu.
$menu = menu_tree_page_data($menu);
// Trim to the needed portion, start at parent menuID.
foreach($menu as $m) {
if ($m['link']['mlid'] == $parent) { // mlid is i18n tranlsation friendly.
$menu = $m['below'];
break;
}
}
// Build the jump menu.
$options = array();
_CUSTOM_jump_menu_create_options($options, $menu);
// Output
if (count($options) == 0) {
return 'Jump menu contains no items!';
} else {
return jump_quickly($options, 'custom', TRUE);
}
}
// Recursive menu into select option building.
function _CUSTOM_jump_menu_create_options(&$o, &$m) {
foreach ($m as $item) { // set the option
// allow for special menu item dummy items for grouping
if (module_exists('special_menu_items') && $item['link']['page_callback'] == 'special_menu_items_dummy') {
$o[] = t($item['link']['title']);
} else {
// Create a normal option.
$o[ $item['link']['href'] ] = ' - ' . t($item['link']['title']);
// TODO: output based on depth
}
if ($item['below']) { // loop deeper
_tab_jump_menu_create_options($o, $item['below']);
// TODO: manage depth
}
}
}
?>
Willing to manage the "GO" button myself, unless that's actually done in the V2 branch?
#3
#4
Exploring a CTools jump menu solution as well... anyone feel free to ping about that.
#5
Went for that...
Created a module: http://drupal.org/project/jump_menu