Make Custom Menus Available to Content Types

Published April 2, 2011

With the introduction of Drupal 7, developers may encounter a puzzling problem involving custom menus: imagine that you have created a custom menu — such as a list of secondary links for the footer of a website — and at least one of its menu items is pointing to a node. You think of an improvement to that node's content, so you edit the node and save the results. But its corresponding menu item has disappeared from your custom menu, and has somehow reappeared on the Main menu! How did that happen?

This (mis)behavior is not seen in Drupal 6, because in Drupal 6, when you are editing a node, in its "Menu settings" section the "Parent item" listbox includes all of the menus, including any custom ones. Consequently, the association between that node and its previously-assigned menu item, can be preserved on any node change — and is preserved, by default. In contrast, for Drupal 7, no custom menus are listed by default. Because only the "Main menu" is listed by default, any change to the node content will also change the parent menu from the custom menu to the Main menu.

To avoid this problem, if and when you create any custom menus in a Drupal 7 website, edit all of the content types for the nodes you want to use as destinations for that menu. For each content type, in its "Menu settings" section, for the "Available menus", enable your custom menu. That way, your custom menu will always be available as a potential parent menu for any nodes of that type, and any changes to your custom menu's nodes will not inadvertently change their parent menus.

This DrupalEasy Quicktip is from Michael J. Ross, a freelance website developer.

Comments

Sign up to receive email notifications of whenever we publish a new blog post or quicktip!

Name
CAPTCHA