When I add a child page to a book page that does not yet have childs, an error occurs:
Notice: Undefined variable: lastWeight in Drupal\book_link_weight\Form\BookLinkWeightForm->alterBookOutlineForm() (line 85 of modules/book_link_weight/src/Form/BookLinkWeightForm.php).
Drupal\book_link_weight\Form\BookLinkWeightForm->alterBookOutlineForm(Array, Object) (Line: 15)
book_link_weight_form_node_form_alter(Array, Object, 'node_book_form') (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'node_book_form') (Line: 836)
Drupal\Core\Form\FormBuilder->prepareForm('node_book_form', Array, Object) (Line: 279)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 706)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
If parent page already have any childs error does not occurs.
Sorry for my english )
And I'm sorry - I don't know how to properly ask for help. You write that you were inspired by the Menu Link Weight module to create this module. Menu Link Weight module has an integration with the Client-side Hierarchical Select module, which simplifies the selection of the parent menu item - is it possible to do the same integration in your module in order to simplify the selection of the parent book page?
Comments
Comment #2
Mr.Torture commentedComment #3
avpadernoComment #4
andy_w commentedOn the first issue, good spot, I have attached a patch here, and will bundle it into a new version, as it should have been there.
As far as integration with cshs goes this would be a much bigger piece of work, as book already has a far better (but also different) interface for parent selection, and already uses ajax to make the selection better.
Therefore book_link_weight would not be able to integrate with cshs in the same way.
Comment #6
andy_w commentedComment #7
avpadernoComment #8
Mr.Torture commentedThanks for the quick response - the patch helped and the error doesn't appear anymore.
Regarding the integration with the CSHS module - the existing interface for editing the hierarchy of books is available only to administrators, we have a lot of materials (tens of thousands) on our site in a very ramified hierarchy of various books, very often there is a situation when users need to move child pages from one parent to another or from one book to another - using the existing standard user interface to select the parent page is a real hell in a situation like this - a hierarchical choice would make it incredibly easy.
Sorry for my english - i used google-translate.
Comment #9
andy_w commentedIf I understand correctly I think altering the permissions to open up levels of access would be beyond the scope of this module, there is however a patch for the book module that might solve the problem: https://www.drupal.org/project/drupal/issues/502430
Comment #10
Mr.Torture commentedThe module you specified is for the Drupal 7 core ... And according to the description, it is far from what we need (((
Sorry for the delay in answering - my time zone is GMT + 10 (hello to flat earthers)
Comment #11
andy_w commentedI'm confused by your response, you specified your issue was with the fact that your users were unable to make use of the book admin widgets.
The patch linked to is for Drupal 8 core (& 9) and will allow users to be granted permission to edit the books.
There are not currently any plans to make this module functional with CSHS as the book module provides suitable functionality for this via Ajax, however I would welcome any additional patches on this. Additionally if you attach screenshots of the experience you are currently having vs what you hope to achieve we could discuss further.
Comment #12
Mr.Torture commentedSorry - I was mistaken about the Drupal version, but still this patch is not for my problem. We have a very branched hierarchy of books on our site. The creation of new child pages does not cause problems - went to the desired section, clicked "add child page" and you're done. But very often there are situations when it is necessary to move a section of a book to another parent section, for example, if it was mistakenly placed in the wrong section, or, for example, when information that has lost its relevance needs to be moved to an "archive" section. The posting of information on the site is mainly done by elderly people who cannot be entrusted with administrator rights, since they can accidentally spoil something. Therefore, for editing the hierarchy of books, they only have access to a standard user interface, which is extremely inconvenient when a book has a huge number of sections and subsections, like ours - to select a parent section, a drop-down list with a full tree of the entire book is used, where the section names are often abbreviated to 2-3 words, which makes the choice extremely difficult.
As you can see in the screenshot, often different sections in this drop-down list are labeled the same. The integration of the MenuLink Weight module with CSHS makes it much easier to select a parent menu item, which has the same standard user interface as books - a drop-down list with a full tree of menu items - thanks to the CSHS integration, each menu level is selected in a separate small list, which is much convenient.
Here's what would be much more convenient to select the parent book.
Comment #13
andy_w commentedSo from investigation I'm pretty sure this could be achieved but it would be a fairly large amount of work, so I'm not sure I'm going to be able to find time for this. Could you copy the above description into a new issue as a feature request so it doesn't get lost as part of the bug being resolved.
Comment #14
Mr.Torture commentedHello. Yes, I perfectly understand that this is a very big job. Thank you for understanding!