In the 6.x book architecture I've noticed that it stores everything in the book table as a mlid / menu reference. It then stores these values in the menu_links table as being associated to JUST that book (of the form book-toc-*). This is great except unlike the rest of the menu structures that exist via creation in menu, it doesn't do an insert into menu_custom (and anywhere else it would need to) in order to be treated as a menu (If you want to test what change this would be, change one of the values in the menu_name column of the menu_custom table to be book-toc-1 after making a book).

This may seem like a subtle change but then projects could standardize on catering JUST to menus and menu handling instead of having to account for books way of working which is similar yet different (like DHTML Menu, Nice Menus, and any of the slue of projects that do menu helper functions). This small "hack" that I propose allows books to utilize Nice menus when they won't support it atm. I'm not suggesting this change to account for a public project but instead of remove the architectural differences that exist between menus and books because they are EXTREMELY similar. A simple check box on the book creation form for something like "Synchronize menu and book hierarchy" would allow for them to be "synced up" by writing the correct entry to one database table. This way the advantages of both could be leveraged in their entirety because you could have pages that have:
* prev / next pagination
* "Short titles" when displayed in menus instead of potentially reaaaallly long book page titles
* Use of books structured content by cool usability modules like DHTML, Nice and anything else out there

I'm going to be writing this "hack" into one of my modules for a 6.x version but figured it might be something everyone would want the option to do because of the flexibility it could provide

Comments

keinstein’s picture

If you do that, please stay in sync with the menu_node module. We had recently some issue with duplicate entries, which are removed now, but would come back if you don't honour this module. For further information see #526756: Duplicate entry errors on menu item update.

I would like if the book module could make just special menus. And I would like the idea to have the opportunity to grant access based on book chapters. This could be achieved by this unification.

j0rd’s picture

I'd like to see more integration between Books and Menus myself.

Here's what I'm doing, which high lights some shortfalls of the book module alone, which integrating it further into the menu system could resolve.

I'm generating a nice_menu based off the books menu entries. This is mildly hackish, but works fine:

  $books = book_get_books();

  $primary = '<ul class="nice-menu nice-menu-down" id="nice-menu-book">';
  foreach($books as $nid => $book) {
      // use this is you have a single root you want to turn into a menu
      //$menu = theme('nice_menus_tree', $book['menu_name'], $book['mlid'], $depth = -1, $m = NULL);
      // use this if you have a book for root menu item
    $menu = theme('nice_menus_tree', $book['menu_name']);
    $primary .= $menu['content'];  
  }     

My issue is that some of the titles of these nodes are too long for the menu. Ideally I would like to maintain, a menu title and a node page title. Currently this is not possible with the book module. Deeper integrations into the menu system would allow this. Currently I'm hacking in this functionality using form_alter & menu_links.options & hook_alter_links.

Another issue I have is that I'd like to be able to link in other content into my menu aside from just the books. Things like Views or module pages. Since the book module only deals with it's own content, I'm unable to add the extra items into the menu.

I'd like to see something a little more robust than the book module. Abstracting the functionality out, which would provide us a simple way of storing all our content in a hierarchical tree easily with minimal setup and fuss.

Damien Tournoud’s picture

Version: 7.x-dev » 8.x-dev
btopro’s picture

Why is this part of core (optional) anyway? It's a glorified menu add-on which, don't get me wrong, I use for everything. It seems more a "drupal does books hooray" then something that really is a necessity to most sites. Drops drupal's footprint, gives it the ability to move and get closer to menus on it's own.

jhedstrom’s picture

Version: 8.0.x-dev » 8.1.x-dev

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

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.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.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.

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.

ptmkenny’s picture

Status: Active » Closed (works as designed)

This issue is a discussion for the book module as it was in D6.

The book module has changed significantly in D8.

I am closing this for now, but if there is a more specific feature request for D8/D9, feel free to re-open with a specific request.