The current codebase does not provide support for managing menu links in OG menus from within the node form.
When adding or editing a node, a menu link can only be added / edited in the core menus that are made available for that content type.
In our use case, we also want editors to add menu links to the OG menus they have access to from within this UI.
Since the OG menus are not listed on the content type "available menus" third-party settings form, and given we don't want to manually select the dynamically created OG menus for each content type anyway, some custom code will be needed to achieve this.
Comment | File | Size | Author |
---|---|---|---|
#21 | og_menu-n2885625-21.patch | 19.17 KB | DamienMcKenna |
#21 | og_menu-n2885625-21.interdiff.txt | 550 bytes | DamienMcKenna |
#19 | og_menu_2885625_19.patch | 19.17 KB | Fernly |
#18 | og_menu_2885625_18.patch | 18.41 KB | Fernly |
#17 | og_menu_2885625_17.patch | 18.38 KB | Fernly |
Issue fork og_menu-2885625
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:
Comments
Comment #2
svendecabooterAttached is a patch that provides this functionality.
Included in this patch:
* Updated the OgMenuParentFormSelector service to show both core menus as well as OG menus
* Updated the OgMenuParentFormSelector service to add access control checks for OG menus
* Added extra form_alter logic to set the default menu link retrieved from an OG menu
Comment #3
svendecabooterUpdated patch that filters out core menus from the parent selector, in case user does not have global permission to manage menus, but still has OG-based permission to manage their specific OG menu instance(s).
Comment #4
svendecabooterUpdated patch fixes a PHP notice error.
Comment #5
svendecabooterComment #6
autopoietic CreditAttribution: autopoietic at Torchbox commentedMinor amendment to check in updated patch, to avod potential Undefined index: menu issue.
Comment #7
zerolab CreditAttribution: zerolab at Torchbox for The Chartered Society of Physiotherapy commentedHere is a new patch that fixes an incorrect permissions
Comment #8
heddnCan we do this on a base entity alter form? That way this is supported for things beside nodes?
Comment #9
mpp CreditAttribution: mpp at AmeXio for District09 commentedIt might make sense to limit the list of og menu's to the ones for the current group(s).
Someone could change the group(s) on the node edit so I presume it is not possible to make this solution generic?
Comment #10
ducktape CreditAttribution: ducktape at District09 commentedI replaced the MenuParentFormSelector service with a form alter to only load the groups that are applicable to the node, as the service is not aware of any OG context.
Comment #11
mpp CreditAttribution: mpp at AmeXio for District09 commented@heddn, not sure if we want to support attaching entities other than Node to the menu?
@ducktape:
Note the array() => [] notation
=> elseif ($placeholder) {
https://www.drupal.org/docs/develop/standards/coding-standards#controlst...
=> t('Choose a group')
Comment #12
mpp CreditAttribution: mpp at AmeXio for District09 commented@ducktape, we should use a build callback on submit (setRebuild) to fill the #options list.
Comment #14
mpp CreditAttribution: mpp at AmeXio for District09 commentedRerolling #10.
Comment #15
Fernly CreditAttribution: Fernly at Dropsolid for District09 commentedReplaced deprecated entity.manager service by entity_type.manager.
Comment #16
Fernly CreditAttribution: Fernly at Dropsolid for District09 commentedChanged ogmenu_instance access() check to userAccessEntity() in og_menu.module. The check always returned "forbidden".
Comment #17
Fernly CreditAttribution: Fernly at Dropsolid for District09 commentedUpdated patch for latest dev release.
Changes in src/Form/OgMenuInstanceForm.php are removed from patch because already committed.
Comment #18
Fernly CreditAttribution: Fernly at Dropsolid for District09 commentedFix missing menu_name array key in og_menu_get_menu_link_defaults().
Comment #19
Fernly CreditAttribution: Fernly at Dropsolid for District09 commentedRerolled patch for Drupal 10
Comment #20
DamienMcKennaThe logic here interferes with core's standard node form logic.
Comment #21
DamienMcKennaI'm not sure why og_menu_form_node_form_alter() includes logic to force $form['menu']['enabled']['#default_value'] to be TRUE on new nodes, so this changes it subtly.