Getting menu links: correct chain of API functions In my module, I need to create sort of a menu block consisting of certain menu items collected from various menus, and flattened into one level.

I'm not sure about the correct chain of the Menu API functions to call. My first attempt was as follows:

function _MYMODULE_block_view(){
  $html = '';

  $menu_link = menu_link_get_preferred('node/287');
  $html .= theme('menu_link', $menu_link);
  dpm($menu_link);
  return $html;
}


but it raises an error about several #attributes missing, so I guess this is not the right kind of object to get markup from. The API docs don't really help in understanding what kind of objects/parameters are returned/expected by functions, hence the question.

Edit:

Having given what Drupal complained about, the code now is as follows:

function _MYMODULE_block_view(){
  global $language;
  $langcode = $language-&gt;language;

  $html = '';

  $paths = array(
    'node/287',
    'node/3',
  );

  foreach($paths as $path){
    $translations = i18n_get_path_translations($path);
    if(!empty($translations[$langcode])){
      $i18n_path = $translations[$langcode]['href'];

      $menu_link = menu_link_get_preferred($i18n_path);
      $link = array(
        '#theme' =&gt; 'link',
        '#text' =&gt; $menu_link['link_title'],
        '#path' =&gt; $path,
        '#options' =&gt; array('attributes' =&gt; array('title' =&gt; $menu_link['link_title'])),
        '#below' =&gt; NULL,
        '#title' =&gt; $menu_link['link_title'],
        '#href' =&gt; $path,
        '#attributes' =&gt; array(),
        '#localized_options' =&gt; array(),
        '#prefix' =&gt; '&lt;li&gt;',
        '#suffix' =&gt; '&lt;/li&gt;'
      );
      $html .= theme('menu_link', array('element' =&gt; $link));
    }
  }

  return "&lt;ul&gt;$html&lt;/ul&gt;";
}


It does not spit out errors but... should I really trust it?
Since you're using menu_link_get_preferred() I'm guessing Drupal 7 here...

Theme functions have changed, and parameters now need to be named in an associative array passed to the theme function. So per the theme_menu_link() docs:

$html .= theme('menu_link', $menu_link);


becomes

$html .= theme('menu_link', array('element' =&gt; $menu_link));