mediatribe.net -- Drupal and Web Development

Notice: this post was last updated 5 years 36 weeks ago so it might be outdated. Please be cautious before implementing any of suggestions herein.

Drupal 6: Two menu items pointing to the same page with features

The Drupal features module does not, for the moment, allow you to export two menu items with the same path.

This is a problem if you have a menu structure like this, which is quite common:

  • Resources: path "resources/one"
    • One: path "resources/one"
    • Two: path "resources/two"

Now, we don't want to have a Resources page. Rather, we would like the top "resources" menu item to lead to "reasources/one".

This can be achieved in Drupal, of course, by assigning the "resources/one" path to the menu item "Resources". However if we do this, as of this writing, Features will only export the second "resources/one" menu item.

One way to solve this, which works for me, is to have your menu items look like this instead:

  • Resources: path "resources", redirecting to resources/one
    • One: path "resources/one"
    • Two: path "resources/two"
  • Download and install the path_redirect module.
  • Enable the core path module.
  • admin/build/path-redirect/add: redirect "resources" to "resources/one".
  • admin/build/path/add: create an alias from "resources" to "node" (or whatever else). This will never actually be used, but is required to prevent the menu system from complaining that the path "resources" does not exist. See http://drupal.org/node/808980.
  • Now you can create two menu items in the same menu, one with the path "resources" and one with the path "resources/one".
  • These can be exported in features.

Note the following caveats:

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.