BookOutline::childrenLinks

public BookOutline::childrenLinks(array $book_link)

Formats the book links for the child pages of the current page.

Parameters

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

Return value

array HTML for the links to the child pages of the current page.

File

core/modules/book/src/BookOutline.php, line 105

Class

BookOutline
Provides handling to render the book outline.

Namespace

Drupal\book

Code

public function childrenLinks(array $book_link) {
  $flat = $this->bookManager->bookTreeGetFlat($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['nid'] != $book_link['nid']));
    // Continue though the array and collect the links whose parent is this page.
    while (($link = array_shift($flat)) && $link['pid'] == $book_link['nid']) {
      $data['link'] = $link;
      $data['below'] = '';
      $children[] = $data;
    }
  }

  if ($children) {
    return $this->bookManager->bookTreeOutput($children);
  }
  return '';
}
doc_Drupal
2016-10-29 08:48:18
Comments
Leave a Comment

Please login to continue.