menu reaches a level dept and has children

Displays only when the menu reaches a level dept and has children.

This is a slight (3 lines using MIN_LEVEL) modification from the primary link bar extender which has been tested on Drupal 5.5

<?php
define
("MIN_LEVEL", 2);

$context_menu = FALSE;

// get the menu items that lead to the current menu item
$active_trail =_menu_get_active_trail();

// Did the user reached the desired menu level
if (count($active_trail) > MIN_LEVEL + 1) // ignore count of menu and dept not reaching the minimum
{
 
// get the primary menus id
 
$pmid = variable_get('menu_primary_menu', 0);

 
// does the menu id of the active top-level link match it ?
 
if ($active_trail[0] == $pmid)
  {
   
// assign base menu
   
$base_menu = menu_get_item($active_trail[MIN_LEVEL]);

   
// Filter out nontask items from the base menu
    // Based on Drupal's includes/menu.inc function : menu_get_active_nontask_item
   
$nontask_count = 0;

    foreach (
$base_menu['children'] as $mid) {
     
$item = menu_get_item($mid);

     
// Verify is iterated item is not a task
     
if (($item['type'] & MENU_NORMAL_ITEM)) {
       
// unfiltered types to ignore
       
switch ($item['type']) {
          case
4: // delete
         
break;
        default:
         
$nontask_count++;
         
//print "<br />"; print_r($item); // display filtered content
       
}//switch
     
}//if
   
}//foreach


    // Does the current menu have children
   
if ($nontask_count > 0)
    {
     
$context_menu = TRUE;
    }
  }
}

return
$context_menu;
?>

 
 

Drupal is a registered trademark of Dries Buytaert.