Problem/Motivation
v2 of the module supports the ability to overwrite settings for a menu at the block-level. This comes with the caveat that this only works outside of Layout Builder.
This was originally discussed here: https://www.drupal.org/project/accessible_menu/issues/3539636
Using form alters, there doesn't seem to be a way to get the menu's machine name- or even tell if the block your editing is a menu block- in the side tray. I took a look at how the Menu Block module does it, and they actually make an entirely new block type and then hide the system menu blocks so you can't use them anymore. I don't really want to do this- it seems problematic.
I would like to not do what Menu Block does if possible because it seems like it would become problematic if someone were to uninstall Accessible Menu (the block would break).
Issue fork accessible_menu-3572043
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:
- 3572043-allow-block-level-settings
changes, plain diff MR !11
Comments
Comment #4
nickolajAdded Layout Builder support for block-level Accessible Menu settings. Uses `hook_form_layout_builder_update_block_alter()` and `hook_form_layout_builder_add_block_alter()` to detect menu blocks in the side tray, extracting the menu machine name from the block plugin ID and using the section component UUID for block-level config storage. Also updates `preprocess_block` and `theme_suggestions_block_alter` to resolve Layout Builder component UUIDs when `#id` is NULL.
Comment #5
nickdjmSo idk if I'm missing something, but this doesn't seem to work.
When using this MR, I get the following error when trying to configure a menu block:
NOTICE: PHP message: Uncaught PHP Exception Error: "Call to undefined method Drupal\layout_builder\Form\UpdateBlockForm::getCurrentBlock()" at /var/www/html/web/modules/contrib/accessible_menu/accessible_menu.module line 137I don't see this method anywhere in the code-base, nor is it in the api docs. Where did it come from?
Comment #6
nickdjmComment #7
nickdjmI suspect this initial attempt was AI-generated if I'm being honest. The fact that @nickolaj's account also appears to be deleted and 403ing now also seems suspicious.
I'm carrying forward with some changes to v2 that should help with this.
I am converting all config to third party settings- the reason for doing this is 2-fold:
This isn't to say I'm going to implement 3rd party settings and then wait for layout builder- I still plan on looking into this, but at least there may be some hope to remove extra code in the future.
Comment #10
nickdjmOk, well I've figured it out.
ThirdPartySettings would be a nice-to-have, but we can get this to work without it.
All that's left is to make sure uninstalling cleans things up nicely (which is _why_ ThirdPartySettings would be nice).
Comment #11
nickdjmI have a working version out in 2.0.0-beta3.
Once there's been a bit more testing, then I think we're ready for a full release of 2.0.0