On this page
function menu_node_save
menu_node_save($node)
Helper for hook_node_insert() and hook_node_update().
File
- modules/menu/menu.module, line 525
- 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');
}
}
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!menu!menu.module/function/menu_node_save/7.x