menu_node_get_nodes_by_menu

Versions
menu_node
menu_node_get_nodes_by_menu($menu_name, $load = FALSE)

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.

Code

./menu_node.module, line 109

<?php
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 = '%s'", $menu_name);
  while ($data = db_fetch_object($result)) {
    if ($load) {
      $nodes[$data->nid] = node_load($data->nid);
    }
    else {
      $nodes[] = $data->nid;
    }
  }
  return $nodes;
}
?>

Contact

  • agentrickard [at] gmail [dot] com

Donations

My Amazon.com Wish List