- 🇨🇦Canada joelseguin Ontario, Canada
I've tested with a Drupal 10 install. The new "dynamic" option works great! I believe it's definitely a feature that is worthwhile to incorporate in the module as it is a common scenario. I plan on using it moving foward as it will save from having to select a specific book and help automate that process.
I've tested out the "book_menu_default" option in the patch and I'm getting the following error when saving the option as well as on a book page:
Warning: Undefined array key "#book_title" in template_preprocess_book_all_books_block() (line 374 of core/modules/book/book.module). - First commit to issue fork.
- Status changed to Needs work
over 1 year ago 12:19pm 24 September 2023 - Status changed to Postponed: needs info
over 1 year ago 12:45pm 24 September 2023 - 🇩🇪Germany simonbaese Berlin
Thanks for providing these new features. I tagged a new release for this module and wanted to reroll your patch. But while working on it, I wonder if I fully understand what you are intending to do. Can you please explain in more detail.
1. What is the difference between
dynamic
and theblock_mode
option in core (all pages and book pages). See the description for the core block mode:If Show block on all pages is selected, the block will contain the automatically generated menus for all of the site's books. If Show block only on book pages is selected, the block will contain only the one menu corresponding to the current page's book. In this case, if the current page is not in a book, no block will be displayed. The Page specific visibility settings or other visibility settings can be used in addition to selectively display this block.
2. Would it be enough to rely on the parent
build()
if the newbook_menu_default
is selected? Something like the following:public function build() { if ($this->configuration['book_menu_default']) { return parent::build(); } // Continue with custom book navigation. // ... }
Thanks for your feedback.
Hello! Thanks for your questions!
1.) The reason the
Dynamic
option was added is that we needed a way to only show the menu for the current book. For example, our website has three books (book1, book2, and book3) with their own menu structure. When I navigate to book1, I only need to see the menu for book1. When theblock_mode
was selected withbook pages
, the menu for book1, book2, and book3 was present on book1.Also, since we use layout builder for our content types, it was nice to add the block once and have the block choose the current
$bid
instead of manually selecting the book menu to display.2.) I believe I added this so the menu would retrieve nested data under the selected book page. For example, Book1 has three book pages nested: BookPageTutorial1, BookPageTutorial2, and BookPageTutorial3. All the book pages have three menu items nested as well. When on BookPageTutorial1, update the menu to display the three menu items nested.
Structure on BookPageTutorial1:
Book1
BookPageTutorial1
Tutorial1
Tutorial2
Tutorial3
BookPageTutorial2
BookPageTutorial3Structure on BookPageTutorial2:
Book1
BookPageTutorial1
BookPageTutorial2
Tutorial1
Tutorial2
Tutorial3
BookPageTutorial3I am not sure if adding the
return parent::build();
would give the desired result, but it might. Please let me know if you have any other questions!- Status changed to Needs work
about 1 year ago 2:52pm 13 October 2023 I just put together a new patch that adds the dynamic option for the module's RC2 version.
I also had some issues using the
in_active_trail
variable within my template. I noticed it was being overwritten in thebuildItems()
function. So, I also made some adjustments to ensure thein_active_trail
variable was set correctly.It looks like the
book_menu_default
option wasn't really needed. DeselectingAlways expand the menu
provides the desired result.The patch still needs to be tested.
- Merge request !4Resolve #3264851 Dynamic book menu/book menu default configuration options → (Merged) created by simonbaese
- Status changed to Needs review
about 1 year ago 2:50am 19 November 2023 - 🇩🇪Germany simonbaese Berlin
@anthonygray47 Thanks for rerolling the patch. I opened a merge request to continue on this issue.
- Please test on your page.
- Can you please open a separate issue to resolve the problems with the active trail. I can certainly see that the code should be improved there. It would be nice to have a specific bug description though.
- I understand the use case for the "Dynamic" option now. Certainly, we are not covering all cases here. I think the confusion comes from how core handles the options "Show on all pages" and "Show on book pages only". We can add "Dynamic" for now and work on a more flexible solution in another issue. My idea is to separate the logic of "where" to display and "what" to display (both are coupled right now).
- 🇩🇪Germany simonbaese Berlin
Merging this since I would like to publish a new release soon. Please continue the discussion here if there are further issues. I will open a new issue for the active trail suggestion.
-
simonbaese →
committed f3b7c984 on 1.0.x
Issue #3264851 by simonbaese, anthonygray47, balagan, joelseguin:...
-
simonbaese →
committed f3b7c984 on 1.0.x
- Issue was unassigned.
- Status changed to Fixed
about 1 year ago 8:46am 21 December 2023 Automatically closed - issue fixed for 2 weeks with no activity.