Menu Export is a Drupal 7 module to export menus easily. Menu Export generates a piece of PHP code which you can store, for example inside a simple .inc file provided by your module. This module also provides an interface to import any of this piece of php code . This module is fully inspired by view and panel export features.

Features

  • Export menu tab.
  • Import menu tab.
  • Import function to use inside your own code.

Other modules

Now, other modules can add their own data to the exported code and reimport it.

To export data...

function hook_menu_export($menu_name) {
$export = new stdClass();
$export->element = "toto";
$export->hello = array(
"en" => "world",
'fr' => "monde",
"multi" => array("yeahhhh", "awesome"),
);
$export->foo = "bar";

return array("module_name" => $export);
}

  • As parameter, we have the menu name if needed
  • Build your own data in an array or class
  • Return an array with your module name as key and your data as value

To import data...

function hook_menu_export_import($menu_name, $data) {
// Do something.
}

  • As parameters we have the menu name and the module data
  • No return value needed*.

* As soon as possible, a TRUE/FALSE return value will have to be used to alert the user if the custom process fail or not.

Similar modules

  • Menu Import. The main difference beetwen Menu export and Menu Export/Import is the kind of exported data . Menu Export provide an object structure which helps to import more efficiently, thus a simple cut-and-paste is enough to regenerate to menu. It is also possible to store the data provided inside a file and call the menu_export_menu_import() function inside you hook_install (for example). Menu export aims to provide a structure close to export features provided by ctools or view.

We would recommend you to use Menu Export if you need something to deploy faster your project. Nethertheless you should probably have a look to Menu Export/Import if you need something readable and understandable by non-tech person.

Possible improvements

  • Create a way to be able to revert any changes on a menu, something like the revert feature provided by view.
  • Make this module compatible with drush :
    • drush menu-import
    • drush menu-export
    • drush menu revert
    • and so forth ...

Requirements

  • Drupal 7 (with the core module "Menu" enabled)

Known issues

  • No conflicts, no incompatibilities or bug known so far.
Short name
2337365