You are here

function jump_menu_block in Better Jump Menus 6

Create jump blocks for all menus.

File

./jump_menu.module, line 98
Make use of the CTools jump menu and grabs from an existing menu. See: modules/ctools/includes/jump-menu.inc NOTE: Menu items must be checked as "expanded" for traversing to work.

Code

function jump_menu_block($op = 'list', $delta = 0) {
  $menus = menu_get_menus();
  switch ($op) {
    case 'list':
      $blocks = array();

      // Create block for each menu.
      foreach ($menus as $name => $title) {
        $blocks['jump_menu_' . $name]['info'] = 'Jump Menu: ' . check_plain($title);

        // Menu blocks can't be cached because each menu item can have
        // a custom access callback. menu.inc manages its own caching.
        $blocks['jump_menu_' . $name]['cache'] = BLOCK_NO_CACHE;
      }
      return $blocks;
      break;
    case 'view':
      $menuName = str_replace('jump_menu_', '', $delta);

      // Strip off jump_menu.
      $data['subject'] = check_plain($menus[$menuName]);
      $data['content'] = jump_menu($menuName, 0, FALSE, 0, '-- Select destination --');
      return $data;
      break;
  }
}