We have repeatedly had a requirement for projects to add a sub-menu to a content area of a page (for which menu_block automatically becomes a default choice), but these menu items are regularly required to be displayed as view modes of the content they represent (more often than not as a teaser). So we have created a patch to allow us to manage this from within the block menu. I thought I'd share this as potentially useful functionality for this module, or alternatively we could look at building a new module to do this - should the feeling be that this functionality does not fit within the intention of this module.
This code has not yet been thoroughly tested or used within a yet active project.
Comment | File | Size | Author |
---|---|---|---|
#8 | 2779465-8.patch | 1.8 KB | komalk |
| |||
#6 | 2779465_6_menu_block_alter_hooks.patch | 1.84 KB | andy_w |
Comments
Comment #2
andy_w CreditAttribution: andy_w commentedComment #3
JohnAlbin$params['node']
won't exist for menu links that point at pages that aren't node pages.This is a very interesting feature, but it seems like it would only work in certain, specific menu set ups. Menu block's options are designed to work together and on any menu.
Perhaps Menu Block could add an "module_additions" key to its config so that 3rd party module's could store form-altered settings inside the Menu Block's config? Menu block would need to add an alter hook for its build.
Comment #4
andy_w CreditAttribution: andy_w at Numiko commentedThanks JohnAlbin.
I have now created a sandbox module to handle menu items as view modes, but this requires some method of hooking into and storing settings as per comments, so the patch is attached.
Comment #5
andy_w CreditAttribution: andy_w at Numiko commentedPatched to work in line with the latest release plus 2757215 which looks like it should be approved in the form its in.
Comment #6
andy_w CreditAttribution: andy_w at Numiko commentedFixed against latest release
Comment #7
Chris Matthews CreditAttribution: Chris Matthews as a volunteer and at City of Oaks Design commentedComment #8
komalk CreditAttribution: komalk at Srijan | A Material+ Company for Drupal India Association commentedWorked on #7.
Re-rolled the patch.
Comment #10
oli-chowdhury CreditAttribution: oli-chowdhury commentedHi,
Is there any update on the D9 compatible version?
@andy_w just wonder if you have worked on any further on this patch?
Comment #11
andy_w CreditAttribution: andy_w at Numiko commentedHi @oli-chowdhury,
I have just pushed up a Drupal 9 compatible version of the menu block view modes sandbox module (https://git.drupalcode.org/sandbox/andywhale-2796357/-/tree/2.x).
But I am told that the patch above would require the 1.x-dev@dev version of menu_block, which should work.
Comment #12
Dave ReidDon't blocks already support third_party_settings? For example: https://www.drupal.org/project/block_titlelink/issues/2929570 and https://www.drupal.org/project/2345855/issues/2425675 are two examples of block-related modules adding third party settings to block forms to store data. I think whatever is needed for this can possibly use the same system and this change here wouldn't be necessary.
Comment #13
andy_w CreditAttribution: andy_w at Numiko commentedI had overlooked this @dave-reid, thank you :-)
The patch will work with the version of my sandbox module, but you're right at some point I will try and refactor to make use of third_party_settings (a much better approach).