You are here

function book_menus_preprocess_book_navigation_before in Book Menus 7

Custom preprocess called before book.module's.

This needs to run before because we're hijacking the creation of the book tree so that "non-links" are not considered by book.module when creating the navigation.

See also

book_menus_theme_registry_alter

template_preprocess_book_navigation

1 string reference to 'book_menus_preprocess_book_navigation_before'
book_menus_theme_registry_alter in ./book_menus.module
Implements hook_theme_registry_alter().

File

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

Code

function book_menus_preprocess_book_navigation_before(&$variables) {

  // Get the book link.
  $book_link = $variables['book_link'];

  // Get the flat menu if there is one.
  $flat =& drupal_static('book_get_flat_menu', array());

  // Create the flat menu if there isn't one.
  if (!isset($flat[$book_link['mlid']])) {

    // Get the flat menu.
    $flat[$book_link['mlid']] = book_menus_get_flat_menu($book_link);

    // Remove any non-linked pages.
    foreach ($flat[$book_link['mlid']] as $key => $value) {
      if ($value['page_callback'] == 'drupal_not_found') {
        unset($flat[$book_link['mlid']][$key]);
      }
    }

    // Make sure the parent was a valid book page.
    if (!array_key_exists($book_link['plid'], $flat[$book_link['mlid']])) {

      // Setting to TRUE tricks book.module not to display the "up" link.
      $variables['book_link']['plid'] = TRUE;
    }
  }
}