Quick question. How to get mlid value from path of menu item. There is a function called menu_link_load() but it requires an mlid value, but I need something exacly the same function using path.

2 Answers 2


There's no build-in function for this. You can use menu_tree_all_data(), but it returns all the menu. After that you can compare in loops your path with the paths returend. But there is a better and easier answer. Here it is:

$mlid = array();
$q = 'your-path';
$menu_info = db_select('menu_links' , 'ml')
  ->condition('ml.link_path' , $q)
  ->fields('ml', array('mlid', 'plid'))

foreach($menu_info as $key => $value) {
  $mlid[] = $menu_info[$key]->mlid;
  • Yes. Using a db query is the correct solution. One thing to note is that there can be more than one menu link for a given path.
    – donquixote
    Commented Jun 11, 2014 at 8:30
  • you're right about this number of results
    – David
    Commented Jun 11, 2014 at 8:40

Try using menu_get_item(), this should load your menu item directly from your path.

  • No, I've already tried it. It returns info about the page that the menu item corresponds to. But I've already found the answer.
    – David
    Commented Jun 11, 2014 at 8:09

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.