You are here

function menu_node_get_nodes_by_menu in Menu Node API 7

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

Get all nodes assigned to a specific menu.

Parameters

$menu_name: The machine name of the menu, e.g. 'navigation'.

$load: Boolean flag that indicates whether to load the node object or not. NOTE: This can be resource intensive!

Return value

A simple array of node ids.

File

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

Code

function menu_node_get_nodes_by_menu($menu_name, $load = FALSE) {
  $links = array();
  $result = db_query("SELECT mn.nid FROM {menu_node} mn INNER JOIN {menu_links} ml ON mn.mlid = ml.mlid WHERE ml.menu_name = :menu_name", array(
    ':menu_name' => $menu_name,
  ));
  foreach ($result as $data) {
    if ($load) {
      $nodes[$data->nid] = node_load($data->nid);
    }
    else {
      $nodes[] = $data->nid;
    }
  }
  return $nodes;
}