1

I want to get the list of parents for a given menu item. As described at api.drupal.org https://api.drupal.org/api/drupal/modules%21menu%21menu.module/function/menu_parent_options/7 I tried but i am not able to get all the parent of a menu item. As the second argument $item to this function should be menu item i tried this code. For example

<?php
$menu_name = array('management' => 'Management');
var_dump(menu_parent_options($menu_name, menu_link_load(23)));
?>

I want to get the parent list of menu /admin/appearance/list which have mlid = 23. But this code give output

array (size=1) 'management:0' => string '' (length=12)

but output should give /admin/ and /admin/appearance also in output in the form of

menuname:mlid

1 Answer 1

1

Try this and see if it helps

<?php
$menu_arr = menu_get_menus();
echo '<pre>';print_r((menu_parent_options($menu_arr, 23)));
?>
1
  • No it didn't work, you have to pass menu $item argument which you get by menu_get_item(), passing menu link id(mlid) directly is same as menu_parent_options($menu_arr, 0)). It return the full tree including the item itself. Commented Sep 6, 2013 at 11:25

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.