Problem/Motivation

The book content type does not have any way to remove or reorder the placement of the book navigation.

Proposed resolution

Implement hook_entity_extra_field_info() to declare the book navigation, and check for it on node display.

Remaining tasks

Build the necessary changes
Review the changes
Test coverage?

User interface changes

Each book-enabled content type would have a display option for controlling the placement of the book navigation.

API changes

None

Data model changes

None

Issue fork book-2711933

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rbayliss created an issue. See original summary.

rbayliss’s picture

Status: Active » Needs review
StatusFileSize
new1.05 KB

Status: Needs review » Needs work

The last submitted patch, 2: 2711933-book_navigation_display.patch, failed testing.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

bès’s picture

StatusFileSize
new1.59 KB
new1.37 KB

Here is a version of the patch that allow any content type to have the extra field as long are there are in the "allowed in book outlines" list.
Also I removed the "weight" in the render array, as it will be set later by the display configuration.

bès’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: interdiff-2711933-2-3.diff, failed testing. View results

bès’s picture

Status: Needs work » Needs review
StatusFileSize
new1.37 KB

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mindbet’s picture

StatusFileSize
new1.71 KB
new593 bytes

Updating this useful patch to Drupal 9.1

mindbet’s picture

StatusFileSize
new1.63 KB
new986 bytes

Revised patch #17.

Many thanks to @quietone for help with this.

Status: Needs review » Needs work

The last submitted patch, 17: 2711933-17.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

anmolgoyal74’s picture

Status: Needs work » Needs review
StatusFileSize
new2.78 KB
new1.65 KB

I think we need to add field in the entity view display config files.
Not sure if this is the right approach.

Status: Needs review » Needs work

The last submitted patch, 19: 2711933-19.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

anmolgoyal74’s picture

Status: Needs work » Needs review
StatusFileSize
new2.77 KB
new586 bytes

Updated variable name.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

abhijith s’s picture

StatusFileSize
new46.4 KB
new42.96 KB

Applied patch #21 and it works fine.The Book navigation can moved/disabled in the book display after applying this patch.Adding screenshots below.

Before patch;
before

After patch:
after

RTBC +1

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

zebda’s picture

I have a book with three levels.

Book
-- Issue
---- Article

It looks like the patch only works on the first level (Book) not on the second level (Issues). I don't see how to change the patch so it also works for other levels. Can anyone help with this?

-- Installed the patch again and it is working now

aaronpinero’s picture

I applied the patch to a Drupal 9.2 site and it appears to work as advertised. RTBC +1

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Feel free to set to RTBC status if you think the patch is ready!

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/book/book.module
@@ -223,11 +223,29 @@ function book_node_load($nodes) {
+  $allowed_types = \Drupal::config('book.settings')->get('allowed_types');
+  if ($allowed_types) {
+    foreach ($allowed_types as $note_type) {
+      $fields['node'][$note_type]['display']['book_navigation'] = [

Should this be $node_type?

rahulkhandelwal1990’s picture

Status: Needs work » Needs review
StatusFileSize
new2.77 KB
new634 bytes

In this patch replaced $note_type by $node_type as suggested in #21, please verify

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

tsurvuli’s picture

This patch is a life-saver, and works great in 9.2.9. However, when we tried to update to 9.3 it fails to apply.

Is there any chance of an update that will work for 9.3/future versions?

aaronpinero’s picture

I have discovered the same problem with Drupal 9.3. The patch will not apply. I've looked at the patch and the code in Drupal 9.3 and it seems like the patch should work. Maybe the line numbers in the patch need to be updated?

zebda’s picture

StatusFileSize
new2.8 KB

I don't know what the problem was but I made a new patch with the same code. And this seems to work.

aaronpinero’s picture

I can confirm that the patch in #33 works with Drupal 9.3

joachim’s picture

Status: Needs review » Needs work

The patch looks like it's failing Drupal code checks. Looks like simple formatting issues.

murilohp’s picture

Assigned: Unassigned » murilohp

I'll fix the issues, thanks!

murilohp’s picture

Assigned: murilohp » Unassigned
Status: Needs work » Needs review
StatusFileSize
new3.2 KB
new1.96 KB

Moving back to needs review to see if it pass.

Thanks!

Status: Needs review » Needs work

The last submitted patch, 37: 2711933-37.patch, failed testing. View results

joachim’s picture

+++ b/core/modules/book/book.module
index 505ab1ee5d..2056a778af 100644
--- a/core/modules/book/config/optional/core.entity_view_display.node.book.default.yml

--- a/core/modules/book/config/optional/core.entity_view_display.node.book.default.yml
+++ b/core/modules/book/config/optional/core.entity_view_display.node.book.default.yml

It also occurs to me that this is probably going to need some sort of update for existing config, as the changes here only apply for fresh installs.

murilohp’s picture

Do you have any idea about how to update the configs for this scenario @joachim? Normally on the contrib modules we see the usage of hook_update, but this idea is not applied for the core.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Postponed

This extension is being deprecated, see #3376070: [Meta] Tasks to deprecate Book module. It will be removed from core and moved to a contrib project, #3376101: [11.x] [Meta] Tasks to remove Book.

This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

This issue may be re-opened if it can be considered critical, If unsure, re-open the issue and ask in a comment.

liliplanet’s picture

That is just amazing! Thank you for the patch quietone and everyone that contributed.

smustgrave’s picture

Project: Drupal core » Book
Version: 11.x-dev » 1.0.x-dev
Component: book.module » Code
Status: Postponed » Needs work

Moving to contrib.

mortona2k’s picture

This patch is doing the same thing as https://www.drupal.org/project/book/issues/3183232

Minor differences in book_entity_extra_field_info() label and description.

Close this one?

damienmckenna’s picture

Version: 1.0.x-dev » 2.0.x-dev

This needs to be reworked as a MR for v2.

damienmckenna’s picture

StatusFileSize
new2.55 KB

Rerolled.

damienmckenna’s picture

Issue summary: View changes
Status: Needs work » Needs review

MR created.

damienmckenna’s picture

mortona2k’s picture

Status: Needs review » Needs work

This is working.

With the patch, I see Book Navigation in manage display, and moving it around or disabling is working.

One issue I ran into is that if you enable a content type to be added to the book, we need to clear the cache to rerun book_entity_extra_field_info().

Seems like that could be done on submission of the book settings config form.

smustgrave’s picture

Status: Needs work » Needs review
mdranove’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed on drupal 10.3 setup with standard install profile.

Testing steps:
1. Ran drush updb.
2. New book navigation field appeared in default and teaser display modes.
3. Moved around book navigation field, worked as expected.
4. Enabled layout builder.
5. Moved around book navigation field on a book node. Worked as expected.

Moving to RTBC.

smustgrave’s picture

Status: Reviewed & tested by the community » Fixed
damienmckenna’s picture

Happy to see this committed, thank you everyone!

That said, do we need a update script to force a cache clear, that way the new hook can be triggered so that the extras field(s) are made visible on appropriate view modes?

It might also be worth enabling the field on the "full" view mode for enabled content types and disabled on other view modes.

smustgrave’s picture

smustgrave’s picture

@damienmckenna normally yes, but there are currently about 3 update hooks already in the next alpha release. For the second part about the view mode made a follow up?

Planning a few more release before marking a stable one.

damienmckenna’s picture

Will do, thank you for the follow-up!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.