This project is not covered by Drupal’s security advisory policy.

Introduction

The menu_migration module helps developers to import and export menu items from one Drupal copy to another one. This was built quickly for a specific project setup, so the options are limited, but it can be extended in the future.

The functionality imports and exports one or more menu items per subsite, so it works with multisite, but most probably it doesn't work with multilingual (Issue Open), and it only manages MenuLinkContent items.

Configuration

The menu items are exported as json in a folder on the server, defined in the configuration form provided by the module.

Settings page
1. Navigate to Configuration → Development → Menu Migration → Settings
2. By default, the export folder is set to ../config/menu_migration, but you can change it to any directory relative to DRUPAL_ROOT
3. When u save this form, you might get an error about permissions, so please make sure that the selected folder has write access for either apache user (if you plan to use the interface) or the shell user (if you plan to use drush), or both.
Export menu items page
4. Navigate to Configuration → Development → Menu Migration → Export
5. Select one or more menus and click on export
6. The items are exported as json in: <export_folder>/sites/<site_name>/<menu_name>/<menu_name>.json
Import menu items page
7. To import, navigate to Configuration → Development → Import
8. Select one or more menus and click on import
9. When importing, all MenuLinkContent items that exist in the target menu(s) will be deleted prior to import

Automation

Menu migration provides two drush commands for managing imports and exports. You can import one or more menus at a time. If you want to import more than one, the menu names need to be separated by commas.

Export menu items with drush

# Export "main" menu.
drush menu_migration:export main
# Export "main", "footer" menus
drush menu_migration:export main,footer
# Alias for export "main" menu.
drush mme main

Import menu items with drush

# Import "main" menu.
drush menu_migration:import main
# Import "main", "footer" menus
drush menu_migration:import main,footer
# Alias for import "main" menu.
drush mmi main

Why alpha?

I'm slowly targeting a stable version, but alpha indicates that the module can still suffer major development changes, so it is not ready yet to go stable. Despite this, the module is in a good shape and continues to be tested/evolved/monitored.

Is it safe?

"Use at your own risk!" is a message that can give you second thoughts. In this particular case, the message simply indicates that security issues can be opened publicly in the issue queue, which could expose vulnerabilities. I prefer to keep it as is while still in alpha, but as a maintainer I do have the vetted role and I can decide at any time to mark the project as "covered by the security advisory policy".

Support

Buy me a 🍺

Supporting organizations: 
AttachmentSize
Export menu items page29.16 KB
Import menu items page28.69 KB
Settings page34.99 KB

Project information

Releases