Problem/Motivation

I would like to have an option in the Plugin configuration to automatically create a menu for new created groups.

Proposed resolution

Add the option and the needed code to make it work.

User interface changes

A new checkbox will appear on plugin configuration.

Comments

jidrone created an issue. See original summary.

jidrone’s picture

Status: Active » Needs review
StatusFileSize
new3.09 KB

Here is the patch.

scotwith1t’s picture

While you're at it, @jidrone, i have another request :) another (sub)option for when a group is created and groupmenu is automatically created, the Group is (can be) automatically added as a "Home" link (default to "Home", customizable text for this?) on the group menu just created. Thanks for all the great improvements!

jidrone’s picture

StatusFileSize
new4.4 KB

Hi Scot,

I added those new options.

anairamzap’s picture

StatusFileSize
new55.23 KB
new19.39 KB
new37.26 KB

Hey! Just a quick note to say this is working as expected:
Once the patch in #4 is applied you should install the Group menu plugin in the Group Type, and then in the "Configure" screen you will get at checkbox to enable the two options:

  1. 1. Auto create a menu for the newly created groups ("Create a menu per group." checkbox)
  2. 2. Add group landing page to the newly created Menu as 'Home' link ("Add group to menu." checkbox)

Screenshot added:
Autocreate Menu Options

Once those two are checked, if you create a new Group you will correctly get a new Menu with a "home" link pointing to the Group landing page.

I would mark this one as Reviewed and Tested, but will let someone else to try it in case I have missed something :)

scotwith1t’s picture

Status: Needs review » Reviewed & tested by the community

Yes! +1 for this super-handy feature! Works as advertised/requested. :)

jidrone’s picture

StatusFileSize
new4.37 KB

Fixed an error when you create groups with long name, reported by Scot:

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Core\Entity\EntityStorageException</em>: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column &#039;menu_name&#039; at row 1: INSERT INTO {menu_tree} (id, menu_name) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array
(
    [:db_insert_placeholder_0] =&gt; menu_link_content:6f2c8829-375c-4e91-8877-d86c86693399
    [:db_insert_placeholder_1] =&gt; johns_hopkins_swallow_for_life_menu
)
scotwith1t’s picture

Status: Reviewed & tested by the community » Needs review

Suppose we should run this by the bot.

scotwith1t’s picture

Perhaps I have to re-upload and have Needs Review status at the same time?

scotwith1t’s picture

Status: Needs review » Reviewed & tested by the community

Oh. There are no tests in this module. Nevermind.

jidrone’s picture

Here is a fix for menu's id and also deleting only auto-created menu when group is deleted.

seanb’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new7.55 KB
new5.51 KB

Made some changes to the patch. Before I commit it, it would be nice if someone could double check everything works as expected and RTBC.

jidrone’s picture

Status: Needs review » Reviewed & tested by the community

I tested it and it's working fine.

  • seanB committed 7d13dc4 on 8.x-1.x
    Issue #3021591 by jidrone, seanB, scotself, anairamzap: Add an option to...
seanb’s picture

Status: Reviewed & tested by the community » Fixed

Fixed! Thanks everyone.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.