Problem/Motivation

When creating a custom menu there isn't an option to link the menu to a content type.
I had the idea to make a custom menu where I could add some basic pages.

The steps I had in mind:
1) Create the menu
2) Create a basic page
3) When creating the page add it to my custom menu

I got stuck on 3 because I couldn't find the menu and I didn't had a clue where to start looking. Untill someone told me I had to edit the content type to allow the new custom menu. This is confusing and there are no hints in the UI you have to do this.

Proposed resolution

Add checkboxes containing the available content types when creating/editing the menu

Remaining tasks

- Current re-roll includes edits to admin page callbacks that no longer exist in Drupal 8.x, so the patch has no effect
- Need to integrate UI changes into the code that generates the menu creation/edit pages in Drupal 8.x
- If creating a new Menu module, needs to have an .info.yml file included
- Maybe change the description of the form element

User interface changes

A new checkboxes form element linking a menu to a content type, or multiple content types.

API changes

No API changes

CommentFileSizeAuthor
#92 1239666-nr-bot.txt144 bytesneeds-review-queue-bot
#90 1239666-90.patch2.69 KBCharchil Khandelwal
#89 1239666-89.patch2.69 KBCharchil Khandelwal
#89 before-patch.PNG40.35 KBCharchil Khandelwal
#89 after-patch.PNG42.17 KBCharchil Khandelwal
#86 after--patch--pic.png15.91 KBvikashsoni
#86 before--patch--pic.png12.42 KBvikashsoni
#85 interdiff_1239666_83-85.txt1.41 KBankithashetty
#85 1239666-85.patch2.69 KBankithashetty
#83 1239666-83.patch2.42 KBSuresh Prabhu Parkala
#76 1239666-menu-content-type-75.patch2.41 KBaleevas
#74 1239666-menu-content-type-74.patch2.41 KBsavkaviktor16@gmail.com
#55 menu-content-type-1239666-55.patch72.77 KBUsha Gavva
#49 1239666-menu-content-type-49.patch27.5 KBtrrroy
#47 1239666-menu-content-type-46.patch13.87 KBtrrroy
#44 1239666-menu-content-type-44.patch13.87 KBtrrroy
#44 interdiff.txt8.42 KBtrrroy
#42 1239666-menu-content-type-42.patch16.63 KBtrrroy
#40 1239666-menu-content-type-40.patch16.63 KBtrrroy
#38 interdiff.txt12.09 KBirunflower
#37 1239666-menu-content-type-37.patch37.57 KBirunflower
#35 1239666-menu-content-type-35.patch12.09 KBtrrroy
#33 1239666-menu-content-type-33.patch10.65 KBtrrroy
#32 1239666-menu-content-type-32.patch4.18 KBtrrroy
#30 1239666-menu-content-type-30.patch4.04 KBtrrroy
#25 1239666-menu-content-type-25.patch4.04 KBtrrroy
#20 1239666-menu-content-type-20.patch4.05 KBryan.gibson
#20 interdiff.txt17.42 KBryan.gibson
#14 1239666-menu-content-type-13.patch3.93 KBaspilicious
#11 1239666-menu-content-type-11.patch3.9 KBaspilicious
#11 menuContentTypeChoose.png18.89 KBaspilicious
#10 1239666-checkbox-menu-10.patch3.92 KBaspilicious
#8 1239666-checkbox-menu-8.patch2.03 KBaspilicious
#4 menuContentTypeLinking.png90.7 KBaspilicious
#4 1239666-checkbox-menu-4.patch2.08 KBaspilicious
#2 1239666-checkbox-menu-2.patch2.12 KBaspilicious
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Bojhan’s picture

Don't we just have checkboxes? I could see that work here too.

aspilicious’s picture

Status: Active » Needs review
FileSize
2.12 KB

Here is a proof of concept patch. It hurted my brain due to the upside down logic of fetching and saving the values.

I don't know if this is the right way to do this. So be gentle ;)

xjm’s picture

Status: Needs review » Needs work

I tested the patch locally, and it functions as expected:

  • There are checkboxes for content types on the menu edit form that correspond to the checkboxes for menus on the content type edit form.
  • Checking the box on the menu for a content type enables it for the menu on the content type form, and vice versa.
  • Either method makes the menu available on the node edit form.
+++ b/modules/menu/menu.admin.incundefined
@@ -465,6 +465,23 @@
+    '#description' => t('some description'),

Obviously, some user instructions would go here. :)

+++ b/modules/menu/menu.admin.incundefined
@@ -593,6 +610,21 @@
+    $content_types = $menu['menu_content_types'];
+    foreach (node_type_get_names() as $content_type => $name) {
+      $menu_options = variable_get('menu_options_' . $content_type, array('main-menu'));

Instead of node_type_get_names(), can we just use the form definition here? Edit: Just during submission, I mean.

+++ b/modules/menu/menu.admin.incundefined
@@ -593,6 +610,21 @@
+        // remove this menu from the content type

Needs capitalization and a period.

+++ b/modules/menu/menu.admin.incundefined
@@ -593,6 +610,21 @@
+        // add this menu to the content type

Ditto.

+++ b/modules/menu/menu.admin.incundefined
@@ -593,6 +610,21 @@
+      // save the new menu options

I'd say either remove this comment, or make it more descriptive.

aspilicious’s picture

Status: Needs work » Needs review
FileSize
2.08 KB
90.7 KB

Thank you for your review. I fixed all of them. Probably needs a better description but I leave that to someone else :).
I attached a screenshot for people that do not understand what this is all about.

aspilicious’s picture

Title: Add the option to add custom menu's to a content type on menu creation » Add the option to add custom menu's to a content type on menu editing

Changing title to reflect the state of the issue

sun’s picture

Status: Needs review » Needs work

The other way around: Node has to integrate with Menu.

sun’s picture

Component: menu system » node.module
Issue tags: -D8UX usability +Usability, +d8ux
sun’s picture

Issue summary: View changes

Small edits

aspilicious’s picture

Title: Add the option to add custom menu's to a content type on menu editing » Add the option to add custom menu's to a content type on menu creating/editing
Status: Needs work » Needs review
FileSize
2.03 KB

In irc we decided this is the correct approach after all. We aldo agreed these checkboxes should also be visible on menu creation, like I planned to do in the beginning.

New patch...

sun’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
+++ b/modules/menu/menu.admin.inc
@@ -465,6 +465,22 @@
+  foreach (node_type_get_names() as $content_type => $name) {

1) No need to check this on menu creation.

2) Could use an inline comment that explains what is being done, as the operation is a bit mind-boggling.

+++ b/modules/menu/menu.admin.inc
@@ -465,6 +465,22 @@
+    if(in_array($menu['menu_name'], $menu_options)) {

Missing space after if.

+++ b/modules/menu/menu.admin.inc
@@ -465,6 +465,22 @@
+  $form['menu_content_types'] = array(

Let's name this 'menu_node_types'.

+++ b/modules/menu/menu.admin.inc
@@ -465,6 +465,22 @@
+    '#title' => t('Available content types'),
...
+    '#description' => t('The content types available that can use this menu.'),

Replace #title with #description and drop the #description.

+++ b/modules/menu/menu.admin.inc
@@ -465,6 +465,22 @@
+    '#options' => node_type_get_names(),

No need to call this twice.

+++ b/modules/menu/menu.admin.inc
@@ -594,6 +610,21 @@
+  $content_types = $menu['menu_content_types'];
+  foreach ($content_types as $content_type => $value) {

Like above, this operation is equally not "obvious", so could use an inline comment explaining what is being done.

+++ b/modules/menu/menu.admin.inc
@@ -594,6 +610,21 @@
+    if (empty($value) && in_array($menu['menu_name'], $menu_options)) {

This in_array() looks superfluous to me.

Lastly, we need tests for this feature.

25 days to next Drupal core point release.

aspilicious’s picture

Status: Needs work » Needs review
FileSize
3.92 KB

Back with a new patch:

Note: I spent 3 hours writing these tests... Nobody is ever going to hire me :p

aspilicious’s picture

New patch and screenshot!

menuContentTypeChoose.png

xjm’s picture

The patch looks good to me, and this seems like a useful parity to have in the UI.

+++ b/core/modules/menu/menu.admin.incundefined
@@ -466,6 +466,26 @@
+    '#title' => t('The content types available that can use this menu.'),

The UI text here is a little weird. Not sure what to change it to, at least not before my coffee. ;)

+++ b/core/modules/menu/menu.testundefined
@@ -157,12 +159,23 @@
+    // Verify article has this menu enabled
...
+    // Verify we can remove the menu again from the node type

I'd suggest changing this to "Verify this menu is listed on the article administration form." and "Disable the menu from the article administration page." (With periods.)

xjm’s picture

Issue tags: -Needs tests

Untagging because the feature has tests.

aspilicious’s picture

Issue tags: +Needs tests
FileSize
3.93 KB

better comments, maybe needs a better description...

sun’s picture

Status: Needs review » Needs work
+++ b/core/modules/menu/menu.admin.inc
@@ -466,6 +466,26 @@
+  $node_types = node_type_get_names();

This entire code needs to be wrapped in a module_exists('node').

Especially due to that, I do not think this feature belongs into Menu module, but instead, Node module should integrate with Menu module.

Both modules are optional. But the actual configuration is primarily used on the node form.

I understand that menu.module already contains integration code in the other direction, but that looks equally bogus to me, now that Node module is optional. At the very least, I'd like to see a follow-up issue to move all of the integration code from Menu to Node module.

+++ b/core/modules/menu/menu.admin.inc
@@ -466,6 +466,26 @@
+  if ($type == 'edit') {
+    // When editing a menu we need to collect all the node types that have this
+    // menu enabled.

We need to explain _why_ the add form case is ignored.

+++ b/core/modules/menu/menu.admin.inc
@@ -466,6 +466,26 @@
+    '#title' => t('Make this menu available to the following content types:'),

1) No semicolon at the end.

2) Could be shortened.

+++ b/core/modules/menu/menu.admin.inc
@@ -466,6 +466,26 @@
@@ -595,6 +615,22 @@

Please double-check your git configuration to create patches with -p to provide more context in diff hunks. (There should be a menu_yadayada_form_submit() context reference on this line.)

+++ b/core/modules/menu/menu.admin.inc
@@ -595,6 +615,22 @@
+  // Check if we need to add or remove this menu from each available node type.

Drop the first part "Check if we need to" without replacement.

yoroy’s picture

Suggestion for the label: "Make this menu available for these content types"

Bojhan’s picture

Or even "Available for these content types" you are already in the activity, of "creating this menu".

The general concept is sound, I remember this being quite awkward when we designed it - as it was a one-way solution.

xjm’s picture

Title: Add the option to add custom menu's to a content type on menu creating/editing » Add the option to add custom menus to a content type on menu creating/editing
Issue tags: +Novice
ryan.gibson’s picture

Assigned: Unassigned » ryan.gibson

I'll take this one.

ryan.gibson’s picture

ryan.gibson’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1239666-menu-content-type-20.patch, failed testing.

xjm’s picture

+++ b/core/modules/menu/menu.admin.incundefined
@@ -476,6 +476,29 @@ function menu_edit_menu($form, &$form_state, $type, $menu = array()) {
+  if module_exists('node') {

This needs parens around the condition.

+++ b/core/modules/menu/menu.testundefined
@@ -133,10 +133,12 @@ class MenuTestCase extends DrupalWebTestCase {
+      "menu_node_types[$type]" => TRUE,

@@ -159,12 +161,23 @@ class MenuTestCase extends DrupalWebTestCase {
+    $edit['menu_node_types[' . $type . ']'] = FALSE;

Really nitpicky, but can we be consistent between these two?

+++ b/core/modules/menu/menu.testundefined
@@ -159,12 +161,23 @@ class MenuTestCase extends DrupalWebTestCase {
+    $this->assertFieldChecked('edit-menu-node-types-' . $type, t('Custom menu added to article node type'));
...
+    $this->assertNoFieldChecked('edit-menu-node-types-' . $type , t('Custom menu removed from article node type'));

Let's strip the t() from these assertion messages. Reference: http://drupal.org/simpletest-tutorial-drupal7#t

trrroy’s picture

Assigned: ryan.gibson » trrroy
trrroy’s picture

patch updated and resubmitted for test

xjm’s picture

Status: Needs work » Needs review

Thanks @trrroy! Setting to "needs review" so the patch can be tested by the testbot and reviewed by reviewers.

So, unrelated. Neither aspilicious nor I can remember why we decided with sun that menu should integrate with node rather than vice versa. aspilicious thinks it might have had to do with not being able to get the correct $menu array in node. (We really should have documented it...) As far as aspilicious recalls, the three of us came to the conclusion that it had to be this way, and sun mentioned a followup issue to decouple menu from node. aspilicious didn't know if that issue actually exists.

Tagging for a summary update to straighten this out, and also for research to find a followup issue for further decoupling node and menu.

Status: Needs review » Needs work

The last submitted patch, 1239666-menu-content-type-25.patch, failed testing.

sun’s picture

+++ b/core/modules/menu/menu.test
@@ -133,10 +133,12 @@ class MenuTestCase extends DrupalWebTestCase {
+      'menu_node_types[$type]' => TRUE,

@@ -159,12 +161,23 @@ class MenuTestCase extends DrupalWebTestCase {
+    $this->assertFieldChecked('edit-menu-node-types-' . $type, 'Custom menu added to article node type');
...
+    $edit['menu_node_types[$type]'] = FALSE;
...
+    $this->assertNoFieldChecked('edit-menu-node-types-' . $type , 'Custom menu removed from article node type');

The key needs to be in double-quotes, as it contains a $variable you want to be expanded.

The variable expansion is the reason why double-quotes are slightly slower, and thus, why we generally use single quotes everywhere, unless double quotes are needed.

That said, the surrounding code in this test uses single quotes with string concatenation of $type. Beautiful code is consistent, so please decide on one way :) (I think I'd personally go with double quotes here)

xjm’s picture

Status: Needs work » Needs review
Issue tags: +Needs issue summary update

No, really.

trrroy’s picture

Changing to double quotes.

sun’s picture

I'm fine with this patch. Only code comments could use some love - the added code in the form has no explanation at all for what is being done there - and why.

Likewise, the code in the form submit handler accesses a lot of variables without checking whether they actually exist. That said, the test code should be moved into an own test case, and ideally, the test case verify the correct behavior with both Node module being disabled and enabled.

Lastly, there's a very minor coding style error in the test (missing space in array declaration).

trrroy’s picture

I added the comments to form additions and fixed the missing space in array declaration. Still need to check for variables in the submit handler and split out the test case (from comment in 31). I'm just getting my feet wet with test cases, please bear with me.

trrroy’s picture

ok, variables are checked and a new test case is broken out with the node module disabled. I'm getting some warnings from simpletest about "call_user_func_array() expects parameter 1 to be a valid callback, function '_node_add_access' not found or invalid function name" when trying to access 'admin/structure/menu/manage/$menu_name/add'. I'm not sure how to get rid of those.

Status: Needs review » Needs work

The last submitted patch, 1239666-menu-content-type-33.patch, failed testing.

trrroy’s picture

Status: Needs work » Needs review
FileSize
12.09 KB
xjm’s picture

Status: Needs review » Needs work

Thanks @trrroy! I'm working with irunflower during office hours this morning, and she's going to add some code style cleanups to your patch as follows:

  1. +++ b/core/includes/menu.incundefined
    @@ -508,7 +508,13 @@ function menu_execute_active_handler($path = NULL, $deliver = TRUE) {
    +        } ¶
    
    +++ b/core/modules/menu/menu.admin.incundefined
    @@ -476,6 +476,32 @@ function menu_edit_menu($form, &$form_state, $type, $menu = array()) {
    +  // Add the option to add custom menus to a content type on menu ¶
    
    +++ b/core/modules/menu/menu.testundefined
    @@ -580,6 +584,127 @@ class MenuTestCase extends WebTestBase {
    +    module_disable(array('node'));
    +    ¶
    +    // Login the user.
    ...
    +    $this->items = array();
    +    ¶
    ...
    +    $this->items[] = $item2;
    +  }  ¶
    

    Trailing whitespace on all these lines should be removed.

  2. +++ b/core/includes/menu.incundefined
    @@ -627,7 +633,8 @@ function _menu_check_access(&$item, $map) {
    +      // if callback function does not exist, do not set $item['access'] to true
    

    TRUE should be all in caps, the sentence should begin with a capital and end with a period, and there should be articles (e.g. "if the callback function does not exist"). Also, be sure to wrap this comment to 80 chars when it's updated.

  3. +++ b/core/modules/menu/menu.admin.incundefined
    @@ -476,6 +476,32 @@ function menu_edit_menu($form, &$form_state, $type, $menu = array()) {
    +  // creating/editing
    

    I'd say "when creating or updating a menu." Also, the comment needs to end in a period.

  4. +++ b/core/modules/menu/menu.admin.incundefined
    @@ -476,6 +476,32 @@ function menu_edit_menu($form, &$form_state, $type, $menu = array()) {
    +    // add checkboxes to the form for each content type
    

    Needs capitalization and a period.

  5. +++ b/core/modules/menu/menu.testundefined
    @@ -580,6 +584,127 @@ class MenuTestCase extends WebTestBase {
    +   * Login users, add menus and menu links, and test menu functionality through the admin and user interfaces.
    

    This needs to be 80 characters or less and begin with a third-person verb. Also, can we clarify a little what the test is testing?

  6. +++ b/core/modules/menu/menu.testundefined
    @@ -580,6 +584,127 @@ class MenuTestCase extends WebTestBase {
    +    // No standard user tests because there are no accessible menu links to $std_user.
    

    This comment is over 80 characters long and should be wrapped earlier.

  7. +++ b/core/modules/menu/menu.testundefined
    @@ -580,6 +584,127 @@ class MenuTestCase extends WebTestBase {
    +  /**
    +   * Test standard menu functionality using navigation menu.
    +   *
    +   */
    ...
    +   * Test custom menu functionality using navigation menu.
    +   *
    +   */
    ...
    +  /**
    +   * Test menu functionality using navigation menu.
    +   *
    +   */
    

    These docblocks all have superfluous blank lines after the summary, and should begin with a third-person verb (e.g. "Tests"). Also, the docs should be a little more specific (describing what the tests are doing).

  8. +++ b/core/modules/menu/menu.testundefined
    @@ -580,6 +584,127 @@ class MenuTestCase extends WebTestBase {
    +    // Note in the UI the 'mlid:x[hidden]' form element maps to enabled, or
    +    // NOT hidden.
    

    Can we clarify this comment more?

When submitting a new patch, please include an interdiff so @trrroy can easily see the changes we're making.

irunflower’s picture

Status: Needs work » Needs review
FileSize
37.57 KB

Updated.

In #36, comment #1, the last part of trailing white space - couldn't find trailing white space in:

+    module_disable(array('node'));
+    ¶
+    // Login the user.
...
+    $this->items = array();
+    ¶

In #6, comments #7 and #8 still have to be addressed.

irunflower’s picture

FileSize
12.09 KB

Interdiff made. First time making an interdiff, but I checked the comparisons between the patches, and I think I made this correctly...

aspilicious’s picture

Status: Needs review » Needs work
+++ b/core/modules/menu/menu.testundefined
@@ -580,6 +584,126 @@ class MenuTestCase extends WebTestBase {
+    ¶

Trailing whitespaces

You got a lot of trailing whitespaces in your patch.
You should configure your editor so it removes them automaticly.

12 days to next Drupal core point release.

trrroy’s picture

Thanks @irunflower! I'm new to interdiffs too so I'm not certain but I don't think that #38 had all your changes in it. I pulled from 37, checked whitespaces and completed 6/7/8 from #36. I'm pretty sure its all in here so far.

trrroy’s picture

Status: Needs work » Needs review
trrroy’s picture

oops, I found more whitespace. try this again.

xjm’s picture

Status: Needs review » Needs work

This is looking a lot better! Thanks @irunflower and @trrroy.

I've reviewed the latest patch and noticed the following:

  1. +++ b/core/includes/menu.incundefined
    @@ -508,7 +508,13 @@ function menu_execute_active_handler($path = NULL, $deliver = TRUE) {
    +          debug($router_item['page_callback'] . ' function does not exist.[1]');
    

    Uh. Stray debug.

  2. +++ b/core/includes/menu.incundefined
    @@ -627,7 +633,9 @@ function _menu_check_access(&$item, $map) {
    +      // If the callback function does not exist, do not set $item['access'] to
    +      // TRUE.
    

    An explanation of "why" would be good in this comment.

  3. +++ b/core/modules/menu/menu.admin.incundefined
    @@ -476,6 +476,32 @@ function menu_edit_menu($form, &$form_state, $type, $menu = array()) {
    +  // Add the option to add custom menus to a content type when creating or
    +  // updating a menu.
    ...
    +      // When editing a menu we need to collect all the node types that have
    +      // this menu enabled.
    
    +++ b/core/modules/menu/menu.testundefined
    @@ -580,6 +583,129 @@ class MenuTestCase extends WebTestBase {
    +    // No standard user tests because there are no accessible menu links to
    +    // $std_user.
    

    I think some of comments are wrapping too early? They should go as close to 80 char as possible without going over. Can you double-check?

  4. +++ b/core/modules/menu/menu.admin.incundefined
    @@ -476,6 +476,32 @@ function menu_edit_menu($form, &$form_state, $type, $menu = array()) {
    +  if (module_exists('node')) {
    

    I may have said this earlier--while this is gross, decoupling menu from node is a significant task and beyond the scope of this issue, so this is acceptable in that sense.

  5. +++ b/core/modules/menu/menu.admin.incundefined
    @@ -580,6 +606,11 @@ function menu_edit_menu_name_exists($value) {
    +  // Abort if menu values do not exist
    

    Missing period. Also, there should be articles (e.g., "Abort if the menu values do not exist."

  6. +++ b/core/modules/menu/menu.admin.incundefined
    @@ -580,6 +606,11 @@ function menu_edit_menu_name_exists($value) {
    +    drupal_set_message(t('There was a problem. Your configuration was not saved.'));
    

    This is a fairly useless error message...

  7. +++ b/core/modules/menu/menu.testundefined
    @@ -31,7 +31,8 @@ class MenuTestCase extends WebTestBase {
    -   * Login users, add menus and menu links, and test menu functionality through the admin and user interfaces.
    +   * Logs in users, adds menus and menu links, and tests menu functionality
    +   * through the admin and user interfaces.
    
    @@ -580,6 +583,129 @@ class MenuTestCase extends WebTestBase {
    +   * With node module disabled, this test logs in users, adds menus and menu
    +   * links, and tests menu functionality through the admin and user interfaces.
    

    These docblocks should begin with a one-line summary that is 80 characters or less and begins with a third-person verb. Reference: http://drupal.org/node/1354#functions

  8. +++ b/core/modules/menu/menu.testundefined
    @@ -49,7 +50,8 @@ class MenuTestCase extends WebTestBase {
    -      $node = node_load(substr($item['link_path'], 5)); // Paths were set as 'node/$nid'.
    +      // Paths were set as 'node/$nid'.
    +      $node = node_load(substr($item['link_path'], 5));
           $this->verifyMenuLink($item, $node);
    
    @@ -80,7 +82,6 @@ class MenuTestCase extends WebTestBase {
        * Test standard menu functionality using navigation menu.
    -   *
    
    @@ -89,7 +90,6 @@ class MenuTestCase extends WebTestBase {
       /**
        * Test custom menu functionality using navigation menu.
    -   *
        */
    
    @@ -142,7 +140,8 @@ class MenuTestCase extends WebTestBase {
    -    // Verify that using a menu_name that is too long results in a validation message.
    +    // Verify that using a menu_name that is too long results in a validation
    +    // message.
    
    @@ -197,7 +196,6 @@ class MenuTestCase extends WebTestBase {
       /**
        * Test menu functionality using navigation menu.
    -   *
        */
    
    @@ -521,7 +523,8 @@ class MenuTestCase extends WebTestBase {
    +    // Retrieve menu link id of the Log out menu link, which will always be on
    +    // the front page.
    
    @@ -679,7 +805,8 @@ class MenuNodeTestCase extends WebTestBase {
    -    // Assert that disabled Management menu is not shown on the node/$nid/edit page.
    +    // Assert that disabled Management menu is not shown on the node/$nid/edit
    +    // page.
    
    @@ -701,7 +828,8 @@ class MenuNodeTestCase extends WebTestBase {
    -    // Assert that it is not possible to set the parent of the first node to itself or the second node.
    +    // Assert that it is not possible to set the parent of the first node to
    +    // itself or the second node.
    

    These changes, while (in most cases) correct by our coding standards, are out of scope for the issue. When code style errors exist elsewhere in core, we should fix them in followup issues (e.g. #1326672: Clean up API docs for menu module). In this patch, we should only make sure that new or changed lines comply with the standards, and not change other lines. See: http://xjm.drupalgardens.com/blog/core-mentoring-and-xjms-guide-patch-re...

  9. +++ b/core/modules/menu/menu.testundefined
    @@ -246,8 +244,8 @@ class MenuTestCase extends WebTestBase {
    +    // Test a hidden menu link. Note in the UI the 'mlid:x[hidden]' form element
    +    // maps to enabled, or NOT hidden.
    
    @@ -580,6 +583,129 @@ class MenuTestCase extends WebTestBase {
    +    // Test a hidden menu link. Note in the UI the 'mlid:x[hidden]' form element
    +    // maps to enabled, or NOT hidden.
    

    This comment could be clarified. "Maps to"?

  10. +++ b/core/modules/menu/menu.testundefined
    @@ -340,9 +338,9 @@ class MenuTestCase extends WebTestBase {
    -  function verifyMenuLink($item, $item_node, $parent = NULL, $parent_node = NULL) {
    +  function verifyMenuLink($item, $item_node = NULL, $parent = NULL, $parent_node = NULL) {
    

    This API change also needs to include an update to the function's docblock to indicate that $item_node is optional.

  11. +++ b/core/modules/menu/menu.testundefined
    @@ -352,9 +350,11 @@ class MenuTestCase extends WebTestBase {
    +        $this->assertTitle(t("@title | Drupal", array('@title' => $title)), t('Parent menu link link target was correct'));
    
    @@ -362,9 +362,11 @@ class MenuTestCase extends WebTestBase {
    +      $this->assertTitle(t("@title | Drupal", array('@title' => $title)), t('Menu link link target was correct'));
    

    We can omit t() from the assertion message here (the final argument). Reference: http://drupal.org/simpletest-tutorial-drupal7#t

    Also, let's add a period to it.

  12. +++ b/core/modules/menu/menu.testundefined
    @@ -580,6 +583,129 @@ class MenuTestCase extends WebTestBase {
    +  /**
    +   * Test standard menu functionality using navigation menu.
    ...
    +   */
    ...
    +  /**
    +   * Test custom menu functionality using navigation menu.
    +   *
    +   */
    ...
    +  /**
    +   * Test menu functionality using navigation menu.
    +   *
    +   */
    

    These should begin with "Tests" rather than "Test". Also, these are the extra blank lines that should be removed, because they are lines we are adding in this patch.

When creating a patch, please read the patch file before uploading to make sure it includes the intended changes. Thanks!

trrroy’s picture

All comments from 43 addressed. On #9, I'm not sure if my change answers the question (also, I'm not sure if I understand the code/comment). On #10, should that docblock be re-formatted with descriptions below the parameters?

trrroy’s picture

Status: Needs work » Needs review
aspilicious’s picture

Status: Needs review » Needs work
+++ b/core/modules/menu/menu.testundefined
@@ -31,7 +31,10 @@ class MenuTestCase extends WebTestBase {
+   * ¶

Trailiing whitespace

+++ b/core/modules/menu/menu.testundefined
@@ -580,6 +585,128 @@ class MenuTestCase extends WebTestBase {
+   * ¶

Trailing whitespace

You should rly look at automated tools to remove whitespace in your editor.
It can save you a lot of trouble! :)

(I had the same whitespace issues in the past)

7 days to next Drupal core point release.

trrroy’s picture

Status: Needs work » Needs review
FileSize
13.87 KB

(arg! there was whitespace in 44! sorry! I thought I checked that.) Please check my questions in comment #44.

sun’s picture

Status: Needs review » Needs work

I'm getting some warnings from simpletest about "call_user_func_array() expects parameter 1 to be a valid callback, function '_node_add_access' not found or invalid function name" when trying to access 'admin/structure/menu/manage/$menu_name/add'. I'm not sure how to get rid of those.

heh. You got rid of those by hacking menu.inc? LOL! But hey, at least I like your creativity :)

All patches since #35 are carrying on this hack, which obviously needs to be removed.

Also, the additional test methods in MenuTestCase have to be moved into an own, new test case class (in case there is no test case for testing the node/menu associations already; I suspect there's probably one in node.test already).

trrroy’s picture

Ok, I removed my hacks and looked for an existing test for node/menu associations but didn't see one. I did move the new MenuNodeDisabledTest into its own test case but I'm back to the same error that I had before that I'm not sure how to get rid of "call_user_func_array() expects parameter 1 to be a valid callback, function '_node_add_access' not found or invalid function name." Any suggestions?

trrroy’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1239666-menu-content-type-49.patch, failed testing.

trrroy’s picture

Assigned: trrroy » Unassigned
trrroy’s picture

Issue summary: View changes

Fixed mistake

xjm’s picture

Component: node.module » node system
Issue summary: View changes

(Merging "node system" and "node.module" components for 8.x; disregard.)

dcmul’s picture

Issue tags: +Needs reroll

A lot of work was put into this one, but its seems like such a long time. Adding tag Needs reroll.

Usha Gavva’s picture

Rerolled the patch from Comment #49

siva_epari’s picture

Please don't remove tags.

jgeryk’s picture

Issue tags: -Needs reroll
vaidehi bapat’s picture

Assigned: Unassigned » vaidehi bapat
Issue tags: +drupalconasia2016

Working on this issue as a part of Drupal Con Asia 2016 code sprint.

vaidehi bapat’s picture

I tried applying patch provided in #55 on latest 8.0.x version. The patch gets applied. However, it doesn't work as expected. No content type links provided while creating or editing menu.

vaidehi bapat’s picture

Status: Needs review » Needs work
vaidehi bapat’s picture

Assigned: vaidehi bapat » Unassigned

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mayurjadhav’s picture

Issue tags: +DrupalMumbaiCodeSprint
nitesh624’s picture

Assigned: Unassigned » nitesh624
nitesh624’s picture

Assigned: nitesh624 » Unassigned

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mohit1604’s picture

I applied patch #55 in my local environment but it does not make any UI changes !

jennine’s picture

I'm at DrupalCon Nashville sprints and I'm going to start looking into this issue!

jennine’s picture

Issue summary: View changes
jennine’s picture

Issue summary: View changes
Issue tags: -Novice +Needs reroll

Tagging this as Needs Reroll again because the reroll in #55 was not sufficient. It replicates the menu.admin.inc file from Drupal 7.x, but the callbacks in that file are no longer present in Drupal 8.x. That's why applying the patch has no effect. Also, since the Menu core module does not exist in Drupal 8.x, #55 would require that module to be installed, which is not possible because there is no .info.yml file.

The patch needs to be rerolled in such a way that it fits into the way menus are managed in Drupal 8.x Core.

savkaviktor16@gmail.com’s picture

Version: 8.5.x-dev » 8.6.x-dev
Status: Needs work » Needs review
FileSize
2.41 KB

I've redone the main part of the patch #49 meaning out of tests according to way menus are managed in Drupal 8.x Core
That's why I didn't make interdiff. I'm not good at creating unit tests, so would be great if someone more experienced will take care of it .

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

aleevas’s picture

The last patch was rerolled successfully.
Solved 2 conflicts in
core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

AjitS’s picture

Issue tags: -Needs reroll

The patch still applies

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Suresh Prabhu Parkala’s picture

A re-rolled patch against 9.3.x. Please review.

chetanbharambe’s picture

Status: Needs review » Needs work

Hi @Suresh Prabhu Parkala,

Above test cases, #83 is getting failed.
Can you please check it once again and attached some before and after screenshots.

Needs to be re-rolled for 9.3.x
Can be a move to Needs work

ankithashetty’s picture

Fixed custom command failure errors in #83, thanks!

vikashsoni’s picture

I have applied patch #85 in durpal-9.3.x-dev after patch we can configure menu for specific content type for ref sharing screenshot

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Charchil Khandelwal’s picture

Version: 9.5.x-dev » 9.4.x-dev
FileSize
42.17 KB
40.35 KB
2.69 KB

Patch No. #85 tested and applied successfully on drupal 9.4.x version.

Charchil Khandelwal’s picture

Version: 9.4.x-dev » 9.5.x-dev
FileSize
2.69 KB

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
144 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.