You are here

function menu_block in Drupal 6

Same name and namespace in other branches
  1. 4 modules/menu.module \menu_block()
  2. 5 modules/menu/menu.module \menu_block()

Implementation of hook_block().

File

modules/menu/menu.module, line 269
Allows administrators to customize the site navigation menu.

Code

function menu_block($op = 'list', $delta = 0) {
  $menus = menu_get_menus();

  // The Navigation menu is handled by the user module.
  unset($menus['navigation']);
  if ($op == 'list') {
    $blocks = array();
    foreach ($menus as $name => $title) {
      $blocks[$name]['info'] = 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[$name]['cache'] = BLOCK_NO_CACHE;
    }
    return $blocks;
  }
  else {
    if ($op == 'view') {
      $data['subject'] = check_plain($menus[$delta]);
      $data['content'] = menu_tree($delta);
      return $data;
    }
  }
}