Drupal - How can I create a view of child nodes based on the menu relationship?

You can do exactly this using the Menu Node API and the Menu Node Views modules.

Create a view with your required content type, and choose a contextual filter of "Menu: Menu link ID" (this is only available with the above modules installed).

Under, "When the filter value is not available," select "Provide default value" and choose "PHP code."

The following snippet will do it, then you just expose a block from the view and you are there:

if (function_exists('menu_node_get_links')){  
   $node = node_load(intval(arg(1)));  
   if (isset($node->menu_node_links)){
      foreach($node->menu_node_links as $mlid=>$data){  
         return $mlid;
      }  
   }
}

One solution is to use taxonomy terms to define the relationships and then to use the Taxonomy Menu module to translate those term relationships into menu items. You can then use the Custom Page module and Context modules to control information and regions on all the pages if you don't want to use panels.


The Node Hierarchy Module allows this type of relationship, as well as providing a views integration.

Node Hierarchy allows nodes to be children of other nodes creating a tree-like hierarchy of content. The module offers:

  • 1-Click creation of hierarchical menus

  • Hierarchical breadcrumbs

  • Automatic hierarchical urls using Pathauto (and token module)

    (eg: q=aboutus/history/beginning).

  • Automatic creation of hierarchical menus if desired.

  • Optional Views integration.

  • Optional Node Access integration.