| 6 menu.inc | menu_link_delete($mlid, $path = NULL) |
| 7 menu.inc | menu_link_delete($mlid, $path = NULL) |
| 8 menu.inc | menu_link_delete($mlid, $path = NULL) |
Delete one or several menu links.
Parameters
$mlid: A valid menu link mlid or NULL. If NULL, $path is used.
$path: The path to the menu items to be deleted. $mlid must be NULL.
Related topics
9 calls to menu_link_delete()
1 string reference to 'menu_link_delete'
File
- includes/
menu.inc, line 2975 - API for the Drupal menu system.
Code
function menu_link_delete($mlid, $path = NULL) {
if (isset($mlid)) {
_menu_delete_item(db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $mlid))->fetchAssoc());
}
else {
$result = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => $path));
foreach ($result as $link) {
_menu_delete_item($link);
}
}
}
Login or register to post comments
Comments
Bug in deleting from path
This doesn't work (but I think it should):
$path = 'node/281';menu_link_delete(NULL, $path);
The cause:
$result = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => $path));should be:
$result = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => $path))->fetchAllAssoc('mlid');... edit ... never mind... I'm wrong. Should be made more clear you can never delete 'system' menu-links.