You are here

function i18n_book_navigation_children in Book translation 7.2

Same name and namespace in other branches
  1. 6.2 i18n_book_navigation.module \i18n_book_navigation_children()

Load the direct child elements.

Port from book_children(). Will perform a similar task, but will also translate the links.

Parameters

array $book_link: The link data

Return value

string The child elements as HTML. If no child elements were found, the string will be empty

See also

book_children()

1 call to i18n_book_navigation_children()
i18n_book_navigation_preprocess_i18n_book_navigation in ./i18n_book_navigation.module
Implements hook_preprocess_i18n_book_navigation().

File

./i18n_book_navigation.module, line 527
Defines the Book translation module.

Code

function i18n_book_navigation_children($book_link) {
  $flat = book_get_flat_menu($book_link);
  $children = array();
  if ($book_link['has_children']) {

    // Walk through the array until we find the current page.
    do {
      $link = array_shift($flat);
    } while ($link && $link['mlid'] != $book_link['mlid']);

    // Continue though the array and collect the links whose parent is this
    // page.
    while (($link = array_shift($flat)) && $link['plid'] == $book_link['mlid']) {
      $data['link'] = $link;
      $data['below'] = '';
      $children[] = $data;
    }
  }

  // Translate the tree.
  $children = i18n_book_navigation_translate_tree($children);

  // Clean it up.
  $children = i18n_book_navigation_cleanup($children);
  $tree = menu_tree_output($children);

  // Render it.
  return $children ? drupal_render($tree) : '';
}