1 menu.module | menu_node_save(Node $node) |
Helper for hook_node_insert() and hook_node_update().
File
- core/
modules/ menu/ menu.module, line 588 - Allows administrators to customize the site's menus.
Code
function menu_node_save(Node $node) {
if (isset($node->menu)) {
$link = &$node->menu;
if (isset($link['enabled']) && !$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";
$link['langcode'] = $node->langcode;
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)) {
backdrop_set_message(t('There was an error saving the menu link.'), 'error');
}
}
}
}