function menu_node_save in Drupal 7
Helper for hook_node_insert() and hook_node_update().
2 calls to menu_node_save()
- menu_node_insert in modules/
menu/ menu.module - Implements hook_node_insert().
- menu_node_update in modules/
menu/ menu.module - Implements hook_node_update().
File
- modules/
menu/ menu.module, line 549 - Allows administrators to customize the site's navigation menus.
Code
function menu_node_save($node) {
if (isset($node->menu)) {
$link =& $node->menu;
if (empty($link['enabled'])) {
if (!empty($link['mlid'])) {
menu_link_delete($link['mlid']);
}
}
elseif (trim($link['link_title'])) {
$link['link_title'] = trim($link['link_title']);
$link['link_path'] = "node/{$node->nid}";
if (trim($link['description'])) {
$link['options']['attributes']['title'] = trim($link['description']);
}
else {
// If the description field was left empty, remove the title attribute
// from the menu link.
unset($link['options']['attributes']['title']);
}
if (!menu_link_save($link)) {
drupal_set_message(t('There was an error saving the menu link.'), 'error');
}
}
}
}