You are here

function menu_node_get_links in Menu Node API 7

Same name and namespace in other branches
  1. 6 menu_node.module \menu_node_get_links()

Get the relevant menu links for a node.

Parameters

$nid: The node id.

$router: Boolean flag indicating whether to attach the menu router link to the $item object. If set to TRUE, the router will be set as $item->menu_router.

Return value

An array of complete menu_link objects or an empy array on failure.

2 calls to menu_node_get_links()
MenuNodeAPIHookTestCase::testMenuNodeAPIHooks in tests/menu_node.test
Run tests against the menu_node_test.module.
menu_node_node_load in ./menu_node.module
Implements hook_node_load().

File

./menu_node.module, line 133
Menu Node API Manages relationships between the {node} and {menu_links} table.

Code

function menu_node_get_links($nid, $router = FALSE) {
  $result = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(
    ':link_path' => 'node/' . $nid,
  ));
  $items = array();
  foreach ($result as $data) {
    if ($router) {
      $data->menu_router = menu_get_item('node/' . $nid);
    }
    $items[$data->mlid] = $data;
  }
  return $items;
}