menu_item_link

Versions
5
menu_item_link($mid, $theme = TRUE)

Returns the rendered link to a menu item.

Parameters

$mid The menu item id to render.

$theme Whether to return a themed link or the link as an array

Related topics

▾ 4 functions call menu_item_link()

menu_get_active_breadcrumb in drupal/includes/menu.inc
Returns an array of rendered menu items in the active breadcrumb trail.
menu_primary_links in drupal/includes/menu.inc
Returns an array containing the primary links. Can optionally descend from the root of the Primary links menu towards the current node for a specified number of levels and return that submenu. Used to generate a primary/secondary menu from different…
theme_menu_item in drupal/includes/menu.inc
Generate the HTML output for a single menu item.
theme_menu_local_task in drupal/includes/menu.inc
Generate the HTML representing a given menu item ID as a tab.

Code

drupal/includes/menu.inc, line 711

<?php
function menu_item_link($mid, $theme = TRUE) {
  $item = menu_get_item($mid);
  $link_item = $item;
  $link = '';

  while ($link_item['type'] & MENU_LINKS_TO_PARENT) {
    $link_item = menu_get_item($link_item['pid']);
  }

  if ($theme) {
    $link = theme('menu_item_link', $item, $link_item);
  }
  else {
    $link = array(
      'title' => $item['title'],
      'href' => $link_item['path'],
      'attributes' => !empty($item['description']) ? array('title' => $item['description']) : array()
    );
  }

  return $link;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.