Acabei de publicar uma função que obtém itens de menu filho, conforme o caminho de um nó. Você pode vê-lo aqui: http://softkube.com/blog/getting-child-menu-items-drupal-menu-tree
Estou incluindo o link para a prova futura da resposta, caso a postagem seja atualizada e também copie / cole o código completo no final.
No seu caso, você pode simplesmente executar algo assim no seu tema para listar todos os itens do menu filho. Modifique a echo
declaração e o tema ao seu gosto.
$path = current_path();
$nids = skl_get_all_menu_node_children_ids($path);
$children = node_load_multiple($nids);
foreach($children as $c) {
echo $c->title . ': ' . url('node/' $c->nid) . '<br />';
}
E aqui está o código completo da função. Verifique o link para possíveis atualizações futuras.
Boa sorte.
/**
* Returns node ids of all the child items, including children of children
* on all depth levels, of the given node path. Returns an empty array
* if any error occurs.
*
* @param string $node_path
* @return array
*/
function skl_get_all_menu_node_children_ids($node_path) {
//Stop and return an empty array if node path is empty
if(empty($node_path)) {
return array();
}
//Init empty array to hold the results
$nids = array();
//Init parent keys. Check 'foreach' loop on parent keys for more info.
$parent_keys = array('plid', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9');
//Collect menu item corresponding to this path to begin updates.
//Reference: http://stackoverflow.com/a/11615338/136696
//Note: we couldn't find a way to get the sub-tree starting from this item
//only and hence we had to get the whole menu tree built and then loop on
//the current item part only. Not so bad considering that Drupal will
//most probably have the whole menu cached anyway.
$parent_menu_item = menu_link_get_preferred($node_path);
//Stop and return empty array if a proper current menu item couldn't be found
if(empty($parent_menu_item['menu_name']) || empty($parent_menu_item['mlid'])) {
return array();
}
//Init parent item mlid for easier usage since now we know it's not empty
$parent_menu_item_mlid = $parent_menu_item['mlid'];
//Build whole menu based on the preferred menu_name gotten from this item
$menu = menu_build_tree($parent_menu_item['menu_name']);
//Reset menu cache since 'menu_build_tree' will cause trouble later on after
//you call pathauto to update paths as it can only be called once.
//Check: https://www.drupal.org/node/1697570
menu_reset_static_cache();
//Init processing array. This will hold menu items as we process them.
$menu_items_to_process = array();
//First run to fill up the processing array with the top level items
foreach($menu as $top_level_menu_item) {
$menu_items_to_process[] = $top_level_menu_item;
}
//While the processing array is not empty, keep looping into lower
//menu items levels until all are processed.
while(count($menu_items_to_process) > 0) {
//Pop the top item from the processing array
$mi = array_pop($menu_items_to_process);
//Get its node id and add it to $nids if it's a current item child
//Note that $parent_keys contains all keys that drupal uses to
//set a menu item inside a tree up to 9 levels.
foreach($parent_keys as $parent_key) {
//First, ensure the current parent key is set and also mlid is set
if(!empty($mi['link']['mlid']) && !empty($mi['link'][$parent_key])) {
//If the link we're at is the parent one, don't add it to $nids
//We need this check cause Drupal sets p1 to p9 in a way you
//can easily use to generate breadcrumbs which means we will
//also match the current parent, but here we only want children
if($mi['link']['mlid'] != $parent_menu_item_mlid) {
//Try to match the link to the parent menu item
if($mi['link'][$parent_key] == $parent_menu_item_mlid) {
//It's a child, add it to $nids and stop foreach loop.
//Link_path has the path to the node. Example: node/63.
if(!empty($mi['link']['link_path'])) {
$nids[] = str_replace('node/', '',
$mi['link']['link_path']);
break;
}
}
}
}
}
//Add its child items, if any, to the processing array
if(!empty($mi['below']) && is_array($mi['below'])) {
foreach($mi['below'] as $child_menu_item) {
//Add child item at the beginning of the array so that when
//we get the list of node ids it's sorted by level with
//the top level elements first; which is easy to attain
//and also useful for some applications; why not do it.
array_unshift($menu_items_to_process, $child_menu_item);
}
}
}
//Return
return $nids;
}
$tree = menu_build_tree('main-menu', array( 'expanded' => array($trail[1]['mlid']) ));
drupal_render(menu_tree_output($tree))
Depois, usando CSS, posso estilizar os links para remover oul
preenchimento, fazendo com que pareçam que estão todos no mesmo nível. Não é o ideal, mas é eficaz. EDIT: desculpe, não consigo descobrir como fazer com quebras de linha funcionem.