You are here

function jump_menu_block_info in Better Jump Menus 7

Register jump blocks for all menus.

File

./jump_menu.module, line 146
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_info() {

  // Add all menus as blocks.
  $menus = menu_get_menus(TRUE);
  $blocks = array();
  foreach ($menus as $name => $title) {

    // Prefix length is 12 chars, leaves 20 for menu name according to 32 char db limit.
    $delta = 'jump_menu-m_' . substr($name, 0, 20);
    $blocks[$delta]['info'] = t('Jump Menu') . ' ' . t('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[$delta]['cache'] = DRUPAL_NO_CACHE;
  }

  // Add local menu tasks block.
  $blocks['jump_menu-local-tasks']['info'] = t('Jump Menu') . ': ' . t('Local tasks');

  // Caching would need to be PER ROLE and PER PAGE.
  $blocks['jump_menu-local-tasks']['cache'] = DRUPAL_NO_CACHE;
  return $blocks;
}