Currently, in the Menu administration page, the admin can set a default menu parent to be shown in the "Parent item" select box of a node's edit form.

I propose that we give the user the ability to explicitly choose which menu(s) appear in the "Parent item" select box. The advantage of this is that it would allow an administrator to control which menus are available to the creator of a node.

This patch adds a multi-select box to the menu administration page, which is used to choose which menus should be shown to the user, and then edits the menu_parent_options() function accordingly.

This patch intentionally does not affect admin pages, so the menu administration pages function normally.

CommentFileSizeAuthor
#89 menu.patch8.39 KBcatch
#86 351249_parent_menu-86.patch8.46 KBstBorchert
#83 351249_parent_menu-83.patch8.56 KBstBorchert
#80 351249_parent_menu-80.patch8.42 KBstBorchert
#77 node_add_after.png24.37 KBsign
#77 node_add_before.png24.12 KBsign
#77 content_type_after.png22.22 KBsign
#77 content_type_before.png18.32 KBsign
#76 351249_parent_menu-75.patch8.47 KBstBorchert
#75 351249_node-add_75.png62.52 KBstBorchert
#75 351249_content-types_75.png63.55 KBstBorchert
#74 351249_parent_menu-73.patch8.35 KBstBorchert
#68 351249_parent_menu-68.patch8.23 KBstBorchert
#65 351249_parent_menu-64.patch6.43 KBsign
#61 351249_parent_menu-61.patch8.23 KBstBorchert
#57 351249_parent_menu-57.patch7.65 KBstBorchert
#56 351249_parent_menu-56.patch6.03 KBstBorchert
#55 parentmenu.patch6.49 KBkkaefer
#48 351239_parent_menu-48.patch4.96 KBstBorchert
#42 351239_parent_menu-42.patch4.28 KBstBorchert
#40 351239_parent_menu-40.patch4.66 KBstBorchert
#38 351239_parent_menu-38.patch4.73 KBstBorchert
#36 351239_parent_menu-36.patch4.62 KBstBorchert
#34 351249_node_type_settings.png8.41 KBstBorchert
#34 351249_node_add_menu.png11.58 KBstBorchert
#33 351239_parent_menu-33.patch4.67 KBstBorchert
#27 content_type-3.png72.69 KBjix_
#25 content_type-2.png73.36 KBjix_
#24 Add or edit content type71.42 KBjix_
#20 test1.JPG23.25 KBmrugesh_drupal
#20 test2.JPG51.54 KBmrugesh_drupal
#20 test3.JPG48.65 KBmrugesh_drupal
#9 parentmenuselect_02.patch3.08 KBcatch
#6 parentmenuselect_02.patch2.21 KBBrightLoudNoise
#6 parentmenuselect_before.png27.12 KBBrightLoudNoise
#6 parentmenuselect_after.png31.95 KBBrightLoudNoise
#2 diff.patch1.98 KBcoreyp_1
diff.patch1.95 KBcoreyp_1
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch failed testing.

coreyp_1’s picture

FileSize
1.98 KB

I'll try it again...

KarenS’s picture

Note that if we combine this with #273137: Split Navigation to User and Administration menu, we could then also set things up out of the box so that the administrative menu items don't show up as available parents when creating story and page nodes. Seeing all those admin items as options confused the heck out of people in the usability testing, so that would be a big win. Has anyone EVER added a story or page to the admin area? I sure haven't, but you have to stumble over all those options every time.

catch’s picture

subscribing.

wretched sinner - saved by grace’s picture

subscribing

BrightLoudNoise’s picture

Patch re-roll and screenshots showing the change for the patch averse.

BrightLoudNoise’s picture

Status: Needs work » Needs review

changing status to needs review

catch’s picture

Tagging.

catch’s picture

FileSize
3.08 KB

We're about to try this at Usability testing after having major menu module issues.

Here's a slight update which removes the two default menu items from the default profile - because people were choosing these as menu parents thinking it'd create a new menu item (similar to how book module does in it's select list).

Also I think we should make the UI for selecting if a menu appears in the parent select a checkbox when editing a menu rather than in the settings tab.

catch’s picture

Issue tags: +UBUserTesting2009

fixing tag.

pwolanin’s picture

I think we should move to the 2x select like the book module has - I hate the single chooser of the menu system.

catch’s picture

jstoller’s picture

subscribing.

jstoller’s picture

I'd like to see this enhancement include the appropriate hooks to allow modification of Parent select options based on user permissions, as well as node type. I'm looking for the ability to restrict where in the site hierarchy my users are allowed to put a node, based on who they are and what kind of content they are uploading.

For instance, here at the California Science Center, I want an exhibit curator to have complete freedom when it comes to creating content that deals with their exhibit gallery. However, they should only be able to put this content in the website section dealing with that exhibit gallery. Our Air & Space curator should never be given the option of sticking his page about the Apollo space capsule in the menu for our IMAX Theater. Every option in the Parent selector should be grayed-out except for those under the Air & Space Gallery section.

If you give users the option of making a mistake, they will make it. Maybe not all the time, but often enough.

wretched sinner - saved by grace’s picture

@jstoller - would the idea of nested menus suit this? I don't know if it has been suggested before, or if it would fit with this issue, but could be a way of doing it.

The way I see it working is to create x menus which refer to different parts of the site, and then a special menu which has the other menus as it's children.

eg you have an Air & Space menu, an IMAX Theatre menu etc, which could then be grouped under one big Navigation menu which the administrator can build. Then you set permissions per menu, which delegates control but allows a constant, single site hierarcy.

jstoller’s picture

Nested menus might help in some cases, but I fear they would quickly become unmanageable. I can easily see a website degenerating in to a tangled mess of nested menus within nested menus, making it impossible to find anything. From a usability standpoint, it seems dangerous to break up the visual of a unified menu hierarchy.

I would prefer adding the ability to assign permissions to branches of the hierarchy directly. I see this happening in two complimentary ways. First, when I create a content type I should be able to restrict where in the menu hierarchy nodes of that type can be placed. Second, when I edit a menu item I should be able to restrict that branch of the menu to specific user roles. When creating a node of a given content type, the menu parent selector would only show menus that work with that content type and which my user roles allow me to access. Within a given menu, only the subset of the hierarchy which I (and the content type) can access should be selectable. The rest of the hierarchy must still be shown (so I know where I am in the site), but should be grayed-out.

This same idea should be carried over to the menu settings page as well. I should only be able to rearrange the subset of a menu's hierarchy that I have permission to manage. The rest of the menu items should be grayed-out and unmovable.

I expect some of these UI refinements could be done in contrib initially, as long as the underlying menu system is built to support the functionality.

beeradb’s picture

I think this all a bit of a derailment. The purpose of this patch is to simplify the UI, not make it overly complicated and allow you to allow you to use specific branches of the menu depending on user role, which is all doable in contrib anyway.

I think we should keep things simple here and offer one option per menu, which is whether or not it shows up as a parentable item.

pwolanin’s picture

Status: Needs review » Needs work

didn't completely review #9, but this looks wrong:

+  $in_admin_page = arg(0) == 'admin';
jstoller’s picture

I'm sorry I pulled this off topic with the user permissions angle, but I'm happy to hear it is possible to implement in contrib.

While I agree this patch is a step in the right direction, I do think it would greatly improve usability if the menus could be associated with content types, rather than just enabled or disabled for all parent selectors. However, I'm happy to request that feature in a separate issue.

mrugesh_drupal’s picture

Title: Finer control over the Parent Menu select box » Really help ful patch you have provided.
FileSize
48.65 KB
51.54 KB
23.25 KB

Hi,

I use your patch it is nicely working but One problem related multilingual site is when I have created the page in dutch under primary-links menu to sub menu item. When i go to edit the page the sub menu do not come to be selected by default.

I am not pointing to your patch solution because by default in drupal case i got the same problem. So if you know the solution for that than please let me know.

As you can see in screen shot.

I have use i18n and language icons module for translations.

Thank you.

pwolanin’s picture

Title: Really help ful patch you have provided. » Finer control over the Parent Menu select box

please don't change the title like that

eigentor’s picture

Related issue: http://drupal.org/node/417106
Remove Management Menu from Parent Selection on Node Form

JohnAlbin’s picture

pwolanin, what's a better way to check if we are in the admin section and, thus, need to override the "hide this menu" functionality?

$in_admin_page = arg(0) == 'admin'; works. But maybe we need to add a flag to toggle that behavior? :-\ Just thinking out loud.

jix_’s picture

Issue tags: +d7uxsprint
FileSize
71.42 KB

Talked with kika about this and we came up with the attached mockup.

The design is definitely not considered ‘finished’ but we think the content type form is a very logical place for these settings. What are your thoughts?

jix_’s picture

FileSize
73.36 KB

Updated mockup with some textual changes and smart defaults.

kika’s picture

We are progressing with the design. After discussion with Dries, Bohjan and Roy we keep the proposed design, just adding more clarity:

- By default, these are the default menu-is-enabled-in-node-add-menu settings per content type:

Main menu: enabled
Management: disabled
Navigation: disabled
Secondary menu: enabled
User menu: disabled

- When user adds new menu, the default menu-is-enabled-in-node-add-menu setting for each content type is enabled

Interaction:

- If user enables / disables menus to display, the default menu item dropdown contents will be updated dynamically -- adding and removing dropdown options
- When user have selected and item from the particular menu and then disables that menu, the default selection falls to the first element remaining in the dropdown
- When user have disabled all menus to display, all elements will be removed from the dropdown AND in node authoring page the "Menu settings" vertical tab is not displayed

jix_’s picture

FileSize
72.69 KB

Forgot to include the user menu — sorry.

mdupont’s picture

Subscribing.

kika’s picture

kkaefer, how is it going with the patch?

rickvug’s picture

Issue tags: +Usability

kika - I completely agree with all points in #26. A few questions:

- Do these limitations effect all users, including admin? Should permissions be taken into account?
- By default, should the article content type have any menus available? IMO, removing the menu fieldset/vertical tab could help ease some of the confusion regarding the difference between a page and article.
- Should there be an additional option to require adding a page to a menu item? Perhaps that is out of scope for this issue.
- (More kitten killing) Moving menu selection into vertical tabs doesn't always make sense if a content type requires it. For example, when creating a page the menu fieldset should be front and center. For content types that that normally do not require a menu, I think hiding the option in vertical tabs makes sense. Perhaps this could be tied to whether adding a menu is required. Alternately, re-arranging the menu form may be best addressed as part of the CCK UI or Fields UI in Core.

Bojhan’s picture

Don't think anyone is working on this. Marking this crtical, since it causes a lot of initial usability problems.

- All users should be affected by this
- I think articles should have menus available.
- Out of scope
- Out of scope as well, this option should probally be tab 1 if required.

yoroy’s picture

Category: feature » task
Priority: Normal » Critical

critical indeed.

stBorchert’s picture

Status: Needs work » Needs review
FileSize
4.67 KB

eigentor asked me to provide a patch for the last shown solution so here it is.

stBorchert’s picture

some screenshots.
#1 is showing the content type settings page with the new "menu settings" fieldset
#2 is showing the menu settings on node creation with pre-selected parent menu item and reduced option list

catch’s picture

This looks great, minor whitespace issue with

+    foreach ($type_menus as $menu) {
+    	$available_menus[$menu] = $menu;
+    }
+    
+  	$item = array('mlid' => 0);
+  }

I'd like to add some variable_set() in the default install profile - to disable the management menu (probably others as well) - could maybe be a separate patch though.

stBorchert’s picture

FileSize
4.62 KB

Hm, don't know where these tabs came from. The editor is set up to use spaces only.
Anyway, here's a new patch with corrected whitespace.

catch’s picture

Status: Needs review » Needs work

Spotted a couple more things:

     return array();
   }
+  $available_menus = menu_get_menus();
+  // If the item is a node type, get all available menus for this type and prepare a dummy menu item.
+  if (!is_array($item) && isset($item)) {
+    $type_menus = variable_get('menu_options_' . $item, array('main-menu' => 'main-menu'));
+    $available_menus = array();
+    foreach ($type_menus as $menu) {
+      $available_menus[$menu] = $menu;
+    }
+
+    $item = array('mlid' => 0);
+  }

$menus is a parameter to the function, and then $available_menus is almost immediately reset when it's set to an empty array - shouldn't we be loaded it later only if needed? Only reading the patch out of context but it looks like we probably don't need to fetch the menus again at all.

t('Choose the menu item to be default for the %menu_settings in the content autherinig form.', array('%menu_settings' => t('menu settings'))),

authering -> authoring. No need to use a placeholder for %menu_settings

stBorchert’s picture

Status: Needs work » Needs review
FileSize
4.73 KB

Ok, I've changed the code to take the given menu items and don't fetch them again.

No need to use a placeholder for %menu_settings

Hm, I acted upon the last mockup in #27.
If you say "no emphasize" I'll go with it.

catch’s picture

You can happily put <em> tags inside t() strings if you want (same with strong etc.), no need to use placeholders for that.

stBorchert’s picture

FileSize
4.66 KB

Ok, I've done it because "menu settings" is the title of the fieldset on node creation and I thought it will be more consistent to translate it only once :-).
But I'm ok with no placeholders.

catch’s picture

OK really sorry this took three passes. The changes to content_types.inc should be in hook_form_node_type_form_alter() - menu module is optional whereas node module isn't, and it saves the module_exists() check. See http://api.drupal.org/api/function/comment_form_node_type_form_alter/7

Other than that looks RTBC to me.

stBorchert’s picture

FileSize
4.28 KB

Ok, now with hook_form_FORM_ID_alter() (don't know why I didnn't thought about it ...).

catch’s picture

Status: Needs review » Reviewed & tested by the community

Looks great now.

Bojhan’s picture

Spend quite some time going over this, looking at the possible alternatives. But with the restraints, I feel this solution is good. I hope the sensible defaults of excluding management menu or whatever the toolbar uses is done correctly.

Looks RTBC from the UX perspective from me.

kika’s picture

Just skimming through the code:

- should we get rid of "Default menu for content" in admin/build/menu/settings ?

- what about upgrade path with that 'menu_default_node_menu' value populating fo all content types 'menu_parent_' . $type->type

- when I unselect all menus in content type form and submit, and try to add that content type node, I will get

"Notice: Undefined variable: options in menu_parent_options() (line 246 of /Users/kristjanjansen/Sites/drupal7/modules/menu/menu.module)."

This is wrong, instead the whole menu vertical tab should go away

- should not "Secondary menu" be enabled by default too?

- What becomes the default value when user selects a menu from the list what is not enabled?

(proposed interaction in #26: If user enables / disables menus to display, the default menu item dropdown contents will be updated dynamically -- adding and removing dropdown options; When user have selected and item from the particular menu and then disables that menu, the default selection falls to the first element remaining in the dropdown)

BTW, kkaefer was working on the same patch, can he provide his work so far?

kika’s picture

Status: Reviewed & tested by the community » Needs work

So, obviously needs work

Bojhan’s picture

- should we get rid of "Default menu for content" in admin/build/menu/settings ?
Yes, but follow up?

- when I unselect all menus in content type form and submit, and try to add that content type node, I will get
bug

- should not "Secondary menu" be enabled by default too?
Not sure, because this is the default for all other themes as well.

- What becomes the default value when user selects a menu from the list what is not enabled?
The behavior you proposed, seems like the one we pursued?

stBorchert’s picture

Status: Needs work » Needs review
FileSize
4.96 KB

Next try.
This time it hides the vertical tab if there are no menus selected.
If you select a disabled menu item as parent it is pre-selected on node creation.

Dries’s picture

While I like this patch, I think it does a poor job explaining what this setting is for. If I were a user new to Drupal, this fieldset would confuse me. There is no context.

Related to that: I don't understand "Menus which should appear in the add menu item section." What is the 'add menu item section'? On the node edit form it is called 'menu settings'?

Bojhan’s picture

-

Bojhan’s picture

I think Dries is right.

"Menus which should appear in the add menu item section."

Should be something like "The menu's available to place links in for this content type.".

Also, why does Default parent item not update anymore on the given selection above?

We had a discussion at the UX-Sprint about this all : http://vimeo.com/groups/drupalux/videos/5676880

stBorchert’s picture

Ok, the latter description sounds much better.

why does Default parent item not update anymore on the given selection above?
Uhm, I never saw this before (or can't remember). Do you mean updating the default parent item based on the selected menus? Dynamically?

Bojhan’s picture

Yes, I was under the impression that - what I select influences the box below.

stBorchert’s picture

Hm, well. This has to be done dynamically.
I'll have to look into some code to figure out how to do this. Stay tuned.

kkaefer’s picture

Status: Needs review » Needs work
FileSize
6.49 KB

Here's a work in progress. There are still some UI glitches but it should work overall.

stBorchert’s picture

FileSize
6.03 KB

Heres my try with dynamically loading the available default menu items.
Its a different approach to kkaefer's patch because it only show menu items from the currently selected menus and did not just disable them.
I know the code could be better (and should be cleaned up) but its a hint how it could look like.
If you deselect all menus, save the content type and then try to select a menu and save the content type again there is an error about an illegal option. Don't know how this can be avoided.

stBorchert’s picture

FileSize
7.65 KB

Uh, I forgot to include the new menu.admin.js. Now it should work (apart from this annoying "illegal choice" error).

Bojhan’s picture

Oke, looking good - probably needs some cleanup as the behavior is somewhat funky now sometimes. We do need to work on the indicator that it has changed.

Bojhan’s picture

Status: Needs work » Needs review

Lets get some reviews up.

stBorchert’s picture

Status: Needs review » Needs work

Well, I did some more testing and found why its not working properly.
If you add some items to the select element ("Default parent item") the form element itself does not know anything about these new items.
Therefore the validation will fail if you select one of the new fields (because its key isn't in the options array of the select-element).

Question: how do we update $form['menu']['menu_parent']['#options'] with the values returned by menu_parent_options_js()? Is this possible at all?
If not, you can't update the available options in "Default parent items" after (de-)selecting one of the "Available menus" checkboxes via AJAX. You'll have to select the available menus first, save and then select the default parent item.

Thoughts?

stBorchert’s picture

Status: Needs work » Needs review
FileSize
8.23 KB

Update the patch: now there are no errors after selecting an item from the "Default parent item" dropdown that was added right before.
See #351249-34: Finer control over the Parent Menu select box for Screenshots (UI did not change).

Status: Needs review » Needs work

The last submitted patch failed testing.

mcrittenden’s picture

Subscribe.

stBorchert’s picture

Status: Needs work » Needs review

Bot? Are you sure?

sign’s picture

FileSize
6.43 KB

Reviewed, looks good, changed one line where atributes class should be an array.

Only one confusing thing for me was:
Main menu is the default menu selected. While adding content (node/add) I see a link called "Add a main menu link". Almost it looked like an action to add a new menu item that needs to be selected.

Status: Needs review » Needs work

The last submitted patch failed testing.

Bojhan’s picture

That is confusing but can be fixed elsewhere.

stBorchert’s picture

FileSize
8.23 KB

@sign: you forgot to include menu.admin.js

sign’s picture

oops, sorry for that :( will make sure to always run patches against clean cvs checkout

reviewed, works fine for me

sign’s picture

Status: Needs work » Needs review
Bojhan’s picture

I applied it, and it behaves as I expected it now.

Dries’s picture

I don't understand why the menu settings aren't part of the Vertical Tabs? That is confusing me.

Bojhan’s picture

Vertical tabs got submitted in between the progress of this patch?

stBorchert’s picture

FileSize
8.35 KB

@Dries: ah, ok. I simply forgot this :-)

stBorchert’s picture

New screenshots.

stBorchert’s picture

FileSize
8.47 KB

Oh and I forgot the new patch (menu.module has changed so it needed a re-roll).

sign’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
18.32 KB
22.22 KB
24.12 KB
24.37 KB

tested, works as expected, screenshots attached :)

kkaefer’s picture

+            $('<option ' + (index == selected ? ' selected="selected"' : '') + '></option').val(index).text(value)

There’s a > missing here.

kkaefer’s picture

Status: Reviewed & tested by the community » Needs work
stBorchert’s picture

Status: Needs work » Needs review
FileSize
8.42 KB

Added the missing character.

Bojhan’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC, this has been reviewed many times now - lets get this sucker in.

Status: Reviewed & tested by the community » Needs work

The last submitted patch failed testing.

stBorchert’s picture

Status: Needs work » Needs review
FileSize
8.56 KB

Rerolled the patch.

Bojhan’s picture

Status: Needs review » Reviewed & tested by the community

Time to put this back to RTBC.

Dries’s picture

Status: Reviewed & tested by the community » Needs work

This patch needs a bit more work.

+++ modules/menu/menu.admin.js	10 Oct 2009 10:55:38 -0000
@@ -0,0 +1,48 @@
+    var vals = [];

We don't abbreviate variables to 'vals'. Write 'values' or 'items' or something else.

+++ modules/menu/menu.admin.js	10 Oct 2009 10:55:38 -0000
@@ -0,0 +1,48 @@
+      // Get the name all checked menus.

This isn't proper English.

+++ modules/menu/menu.module	10 Oct 2009 10:55:40 -0000
@@ -309,6 +315,44 @@ function menu_parent_options($menus, $it
+    // If $item is a node type, get all available menus for this type and prepare a dummy menu item.

Please describe why we prepare a dummy menu item.

+++ modules/menu/menu.module	10 Oct 2009 10:55:40 -0000
@@ -309,6 +315,44 @@ function menu_parent_options($menus, $it
+  if (isset($_POST['menus']) && count($_POST['menus'])) {
+   foreach ($_POST['menus'] as $menu) {
+     $available_menus[$menu] = $menu;
+   }
+  }

Indentation is not according to the coding standards.

+++ modules/menu/menu.module	10 Oct 2009 10:55:40 -0000
@@ -554,6 +609,52 @@ function menu_form_alter(&$form, $form_s
+  // Get all menu items here. If we would provide only available items here
+  // FormsAPI would not allow us to add other items dynamically and select
+  // one of the new items before saving the form. It would show an
+  // 'illegal option' error and cancel the form submission.

This needs some massaging. It reads like broken English. Also, "FormsAPI" should be "Form API".

+++ modules/menu/menu.module	10 Oct 2009 10:55:40 -0000
@@ -554,6 +609,52 @@ function menu_form_alter(&$form, $form_s
+  // Initially update the list of available menu parent items so we only have
+  // the items from the selected menus.

I don't understand this code comment.

stBorchert’s picture

Status: Needs work » Needs review
FileSize
8.46 KB

Hope this one is better.

eigentor’s picture

Forget my comment. Installed the patch, fixes the issue I lamented about.

Dries’s picture

Status: Needs review » Fixed

OK, this looks good enough. Committed to CVS HEAD. We can refine in follow-ups as necessary.

catch’s picture

Status: Fixed » Reviewed & tested by the community
FileSize
8.39 KB

#86 dealt with all of Dries' points. I found a couple of comments which had a summary more than one line, changed Javascript to JavaScript - rather than mark CNW I re-rolled the patches with these changes and am marking RTBC. Please don't credit on commit.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Heh.

None of those were major, we can do those in the 'fix code comments' issues in about a month.

Status: Fixed » Closed (fixed)

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

Gábor Hojtsy’s picture

This was not documented in the update guide, now added http://drupal.org/update/modules/6/7#menu_default_node_menu

Gábor Hojtsy’s picture

This change is missing an upgrade path (although noted by @kika in July 2009 that it would need one). Critical issue opened at #761648: Menu D6->D7 upgrade doesn't maintain node-menu configuration (f.k.a.: Menu items disappear after upgrade or manual menu entry).