On this page
function menu_enable
menu_enable()
Implements hook_enable().
Add a link for each custom menu.
File
- modules/menu/menu.module, line 180
- Allows administrators to customize the site's navigation menus.
Code
function menu_enable() {
menu_rebuild();
$base_link = db_query("SELECT mlid AS plid, menu_name FROM {menu_links} WHERE link_path = 'admin/structure/menu' AND module = 'system'")->fetchAssoc();
$base_link['router_path'] = 'admin/structure/menu/manage/%';
$base_link['module'] = 'menu';
$result = db_query("SELECT * FROM {menu_custom}", array(), array('fetch' => PDO::FETCH_ASSOC));
foreach ($result as $menu) {
// $link is passed by reference to menu_link_save(), so we make a copy of $base_link.
$link = $base_link;
$link['mlid'] = 0;
$link['link_title'] = $menu['title'];
$link['link_path'] = 'admin/structure/menu/manage/' . $menu['menu_name'];
$menu_link = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path AND plid = :plid", array(
':path' => $link['link_path'],
':plid' => $link['plid']
))
->fetchField();
if (!$menu_link) {
menu_link_save($link);
}
}
menu_cache_clear_all();
}
© 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_enable/7.x