0 && $tree_page) { // Loop through the current level's items until we find one that is in trail. while ($item = array_shift($tree_page)) { if ($item['link']['in_active_trail']) { // If the item is in the active trail, we continue in the subtree. $tree_page = empty($item['below']) ? array() : $item['below']; break; } } } return themename_navigation_links_level($tree_page, $tree_all); } /** * Helper function for themename_navigation_links to recursively create an array of links. * (Both trees are required in order to include every menu item and active trail info.) */ function themename_navigation_links_level($tree_page, $tree_all) { $links = array(); foreach ($tree_all as $key => $item) { $item_page = $tree_page[$key]; $item_all = $tree_all[$key]; if (!$item_all['link']['hidden']) { $class = ''; $l = $item_all['link']['localized_options']; $l['href'] = $item_all['link']['href']; $l['title'] = $item_all['link']['title']; if ($item_page['link']['in_active_trail']) { $class = ' active-trail'; } if ($item_all['below']) { $l['children'] = themename_navigation_links_level($item_page['below'], $item_all['below']); } // Keyed with the unique mlid to generate classes in theme_links(). $links['menu-'. $item_all['link']['mlid'] . $class] = $l; } } return $links; } /** * Helper function to retrieve the primary links using themename_navigation_links(). */ function themename_primary_links() { return themename_navigation_links(variable_get('menu_primary_links_source', 'primary-links')); } /** * Return a themed set of links. (Extended to support multidimensional arrays of links.) * * @param $links * A keyed array of links to be themed. * @param $attributes * A keyed array of attributes * @return * A string containing an unordered list of links. */ function themename_links($links, $attributes = array('class' => 'links')) { $output = ''; if (count($links) > 0) { $output = '