I have an entity, when i submit this entity i want to add the new entity created in a menu as a link. But in this menu i have a tree links so i don't know how to put my link in a specific tree. I saw the "mlid" and the "plid", i think "mlid" is the id of the menu and the "plid" is the id of the mother link.

So if I want to add a new item, what do I need to do? Do I get the ID of the parent link? Do I need to use menu_link_save()? How do I construct my new link?

This is the code I am using.

$menu_intervenant_loaded = menu_load_links('menu-intervenant-project'. $idProject);

foreach ($menu_intervenant_loaded as $menu_item) {
  $menutitle = str_replace(" ","+", $menu_item['link_title']);
  $mlid = $menu_item['mlid'];
  $link = menu_link_load($mlid);
  $haschildren = $menu_item['has_children'];
  if ($menutitle == "Entreprises") {
    //The parent link: here is where I need to create my link.
    $item = array(
        'title' => 'Montitre',
        'access' => TRUE,
        'link_path' => 'encore un test',
        'link_title' => 'Mon titre qui fonctionne pas',
        'plid' => $mlid,
        'customized' => 1,
        'external' => 1,


EDIT : With this code the link appear when i debug my menu before submit, but doesn't appear in my administration and front-end where the menu is placed..


1 Answer 1


Value of plid is the menu link id of the item you want your new item to be a child of (=parent id).

To create your link, simply use something like:

$item = array(
  'link_path' => 'node/' . $node->nid,
  'link_title' => $node->title,
  'plid' => 426,
  • Thanks i tried that but the link isn't added to my menu, but when i debug the menu i can see the link added is the link list of this menu. Why he isn't appear in my administration of this menu ?
    – Cracs
    Nov 25, 2014 at 13:34
  • Sorry @Remi I don't understand very well what happens. The link doesn't appear neither in your menu (front-end), nor in the admin (admin->structure->menu) but you see it where??
    – Djouuuuh
    Nov 25, 2014 at 13:37
  • Ok sorry for my english. The link appear when i debug (kpr($link);) my menu, i can see all my links of this menu. But in my "admin->structure->menu" and my "front-end where the menu is placed" the link created doesn't appear.
    – Cracs
    Nov 25, 2014 at 13:41
  • Could you try to add a line in $item array: 'customized' => 1, ?
    – Djouuuuh
    Nov 25, 2014 at 13:44
  • I saved my link with that array: $item = array('link_path' => 'blabla','link_title' => 'Lot 1','title' => 'Lot 1','plid' => $mlid,'customized' => 1); And nothing appear. The link is saved because i can see him if i debug the menu but won't appear in my administration and front-end... So i don't know why.
    – Cracs
    Nov 25, 2014 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.