Problem/Motivation

When creating a node, you can choose to provide a menu link. It would be nice to have the option to provide a menu link when creating a node by default if desired.

Steps to reproduce

NA

Proposed resolution

I propose adding a checkbox under Menu settings when editing a Content type, which would control if a menu link is automatically provided when creating a node of that content type.

Remaining tasks

Review

User interface changes

before
before

after
after

Introduced terminology

NA

API changes

NA

Data model changes

NA

Release notes snippet

NA

Issue fork drupal-3371646

Command icon 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

agile-mark-l created an issue. See original summary.

cilefen’s picture

Version: 9.5.x-dev » 11.x-dev
cilefen’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
ranjith_kumar_k_u’s picture

StatusFileSize
new1.97 KB
new3.56 KB
new6.26 KB

There was an issue with the functionality, so fixed that and added tests.

The current MR was created against 9.5x and I don't have permission to edit, so created patch

ranjith_kumar_k_u’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new953.68 KB
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record

This seems close but I don't see where we are testing that the menu link is pre-checked on the node add page.

Also will need a change record with appropriate screenshots.

ranjith_kumar_k_u’s picture

Status: Needs work » Needs review
StatusFileSize
new1.67 KB
new2.27 KB
new5.95 KB

Hi, I updated the tests, I hope this will be enough

Change record - https://www.drupal.org/node/3373587

The last submitted patch, 8: 3371646-8-tests-only.patch, failed testing. View results

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests, -Needs change record +Needs Review Queue Initiative

Think this is better

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/menu_ui/config/schema/menu_ui.schema.yml
@@ -21,3 +21,6 @@ node.type.*.third_party.menu_ui:
+    link_by_default:

Given the schema change, wouldn't this need an upgrade path?

yoroy’s picture

Issue tags: +Usability

Excellent idea, lets do this. Two questions:

- Provide or create? Maybe create is the simpler word? Lets also add 'a': Create a new menu item by default.
- Was this deliberately put at the bottom of this list of settings? I can also imagine it at the top, as the very first consideration and decision to make for this menu settings section.

chris matthews’s picture

- Provide or create?

"Provide" is the word used in the Menu settings on the node edit form, so it might be best to keep the words consistent.

"Provide a menu link by default."
-OR-
"Provide a menu link by default when saving new content."
-OR-
"Provide a menu link by default when saving new content of this type." - My vote, fwiw

The "...content of this type" phrase comes from two other places:

"Content of this type can be placed in the selected menus."

"This text will be displayed at the top of the page when creating or editing content of this type."

The word "Add" would also make sense as it is used throughout the UI, but between the 3 proposed options (Provide, Create, Add) I'd personally vote for consistency and stick with "Provide", unless we want to change the word "Provide" to something else on the node edit form.

Note: whichever sentence ends up being used it needs a . (period) at the end of the sentence.

- Was this deliberately put at the bottom of this list of settings?

I think it make most sense either right above or right below the Default parent link select list as the two are related.

kunal.sachdev’s picture

Assigned: Unassigned » kunal.sachdev

kunal.sachdev’s picture

Assigned: kunal.sachdev » Unassigned
Status: Needs work » Needs review
omkar.podey’s picture

Status: Needs review » Needs work

The MR looks good overall but I think the testing could be easily extended to check if the link was actually created at admin/structure/menu/manage/main

kunal.sachdev’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems additional test coverage has been added in commit https://git.drupalcode.org/project/drupal/-/merge_requests/4642/diffs?co...

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

See the comment on the MR - we need to rewrite the post update.

alexpott’s picture

Hiding all the files to make this easier to review.

alexpott changed the visibility of the branch 3371646-add-option-to to hidden.

niklp’s picture

+1 for putting it at the top.
I get what Chris Matthews is saying but in natural order I would say something like: "Oh definitely create a menu item by default, these are the menus I would like available, but the default one should be this." That feels right to me.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Closed #3405645: Auto create the menu for node. as a duplicate of this.

Triaging this one

First this needs an issue summary update.

Let me try and get a main branch up for review.

smustgrave’s picture

Issue summary: View changes
StatusFileSize
new84.04 KB
smustgrave’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update
StatusFileSize
new110.97 KB

smustgrave’s picture

Status: Needs work » Needs review

Believe this is ready for review.