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

doublejosh’s picture

Status: Active » Postponed (maintainer needs more info)

I submitted this before I realized that it only showed the top level anyhow.

doublejosh’s picture

Status: Needs review » Postponed (maintainer needs more info)

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...

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?

doublejosh’s picture

Status: Postponed (maintainer needs more info) » Needs review
doublejosh’s picture

Status: Postponed (maintainer needs more info) » Needs review

Exploring a CTools jump menu solution as well... anyone feel free to ping about that.

doublejosh’s picture

Status: Needs review » Active

Went for that...
Created a module: http://drupal.org/project/jump_menu

doublejosh’s picture

Issue summary: View changes

Added details about what I meant.