You are here

function book_menus_get_flat_menu in Book Menus 7

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.

1 call to book_menus_get_flat_menu()
book_menus_preprocess_book_navigation_before in ./book_menus.module
Custom preprocess called before book.module's.

File

./book_menus.module, line 291
Functionality for book_menus.module.

Code

function book_menus_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.
    // Override book.module and remove the second parameter so we get the full
    // book.
    $tree = menu_tree_all_data($book_link['menu_name']);
    $flat[$book_link['mlid']] = array();
    _book_flatten_menu($tree, $flat[$book_link['mlid']]);
  }
  return $flat[$book_link['mlid']];
}