diff --git a/core/modules/book/book.module b/core/modules/book/book.module index bc3e7701..43bc535e 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -223,11 +223,37 @@ function book_node_load($nodes) { } } +/** + * Implements hook_entity_extra_field_info(). + */ +function book_entity_extra_field_info() { + $return = array(); + // Update the list of node types that are allowed to be added to books. + $config = \Drupal::configFactory()->getEditable('book.settings'); + $allowed_types = $config->get('allowed_types'); + + foreach ($allowed_types as $note_type) { + $return['node'][$note_type] = array( + 'display' => array( + 'book_navigation' => array( + 'label' => t('Book navigation'), + 'description' => t('Book navigation links'), + 'weight' => 100, + 'visible' => TRUE, + ) + ) + ); + } + + + return $return; +} + /** * Implements hook_ENTITY_TYPE_view() for node entities. */ function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) { - if ($view_mode == 'full') { + if ($display->getComponent('book_navigation')) { if (!empty($node->book['bid']) && empty($node->in_preview)) { $book_node = Node::load($node->book['bid']); if (!$book_node->access()) { @@ -236,7 +262,6 @@ function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayI $build['book_navigation'] = [ '#theme' => 'book_navigation', '#book_link' => $node->book, - '#weight' => 100, // The book navigation is a listing of Node entities, so associate its // list cache tag for correct invalidation. '#cache' => [