Error message
You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).function menu_save
Save a custom menu.
Parameters
$menu: An array representing a custom menu:
- menu_name: The unique name of the custom menu (composed of lowercase letters, numbers, and hyphens).
- title: The human readable menu title.
- description: The custom menu description.
Modules should always pass a fully populated $menu when saving a custom menu, so other modules are able to output proper status or watchdog messages.
See also
3 calls to menu_save()
- MenuTestCase::addCustomMenuCRUD in modules/
menu/ menu.test - Add custom menu using CRUD functions.
- menu_edit_menu_submit in modules/
menu/ menu.admin.inc - Submit function for adding or editing a custom menu.
- menu_install in modules/
menu/ menu.install - Implements hook_install().
File
-
modules/
menu/ menu.module, line 259
Code
function menu_save ($menu) {
$status = db_merge ('menu_custom')->key (array(
'menu_name' => $menu['menu_name'],
))
->fields (array(
'title' => $menu['title'],
'description' => $menu['description'],
))
->execute ();
menu_cache_clear_all ();
switch ($status) {
case SAVED_NEW :
// Make sure the menu is present in the active menus variable so that its
// items may appear in the menu active trail.
// @see menu_set_active_menu_names()
$active_menus = variable_get ('menu_default_active_menus', array_keys (menu_get_menus ()));
if (!in_array ($menu['menu_name'], $active_menus)) {
$active_menus[] = $menu['menu_name'];
variable_set ('menu_default_active_menus', $active_menus);
}
module_invoke_all ('menu_insert', $menu);
break;
case SAVED_UPDATED :
module_invoke_all ('menu_update', $menu);
break;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.