You are here

function book_get_flat_menu in Drupal 7

Same name and namespace in other branches
  1. 6 modules/book/book.module \book_get_flat_menu()

Gets the book menu tree for a page and returns it as a linear array.

Parameters

$book_link: A fully loaded menu link that is part of the book hierarchy.

Return value

A linear array of menu links in the order that the links are shown in the menu, so the previous and next pages are the elements before and after the element corresponding to the current node. The children of the current node (if any) will come immediately after it in the array, and links will only be fetched as deep as one level deeper than $book_link.

3 calls to book_get_flat_menu()
book_children in modules/book/book.module
Formats the menu links for the child pages of the current page.
book_next in modules/book/book.module
Fetches the menu link for the next page of the book.
book_prev in modules/book/book.module
Fetches the menu link for the previous page of the book.

File

modules/book/book.module, line 721
Allows users to create and organize related content in an outline.

Code

function book_get_flat_menu($book_link) {
  $flat =& drupal_static(__FUNCTION__, array());
  if (!isset($flat[$book_link['mlid']])) {

    // Call menu_tree_all_data() to take advantage of the menu system's caching.
    $tree = menu_tree_all_data($book_link['menu_name'], $book_link, $book_link['depth'] + 1);
    $flat[$book_link['mlid']] = array();
    _book_flatten_menu($tree, $flat[$book_link['mlid']]);
  }
  return $flat[$book_link['mlid']];
}