I'm working on a module in which I have to return part of the Navigation menu as an unordered list in $content (i.e. not in a block). I had this working in Drupal 5.x by stealing code from here: Drupal trick: Returning a themed menu tree with nothing more than the system path.

It worked great! But if there is a way to do something similar in Drupal 6.x, I haven't been able to figure it out. I think the main problem I'm having is I can not for the life of me figure out how to grab a page's $mlid.

If anyone knows how to pull this trick off in 6.x, pleeeeease share. I would be in your debt.

Comments

nikit’s picture

not so good way:

function _get_mlid($path) {
  $mlid = null;
  
  $tree =  menu_tree_all_data('primary-links');

  foreach($tree as $item) {
    if ($item['link']['link_path'] == $path) {
      $mlid = $item['link']['mlid'];
      break;
    }
  }

  return $mlid;
}

jenna.tollerson’s picture

Is that better or worse than just querying the database directly? (Which is what I ended up doing?)
$mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = '%s' ORDER BY mlid ASC", $path, 0, 1));