/** PAGE.TPL.PHP PREPROCESS VARIABLES ---------------------------------------------------------- */ function megatron_preprocess_page(&$variables) { // Secondary nav $variables['secondary_nav'] = FALSE; if ($variables['secondary_menu']) { $secondary_menu = menu_load(variable_get('menu_secondary_links_source', 'user-menu')); // Build links $tree = menu_tree_page_data($secondary_menu['menu_name']); $variables['secondary_menu'] = megatron_menu_navigation_links($tree); // Build list $variables['secondary_nav'] = theme('megatron_btn_dropdown', array('links' => $variables['secondary_menu'], 'label' => $secondary_menu['title'], 'type' => 'success', 'attributes' => array('id' => 'user-menu', 'class' => array('pull-right')), 'heading' => array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible')))); } // Replace tabs with dropdown version $variables['tabs']['#primary'] = _megatron_local_tasks($variables['tabs']['#primary']); }
/** THEME MEGATRON MAIN MENU LINKS Returns navigational links based on a menu tree */ function megatron_menu_navigation_links($tree, $lvl = 0) { $result = array(); if (count($tree) > 0) { foreach ($tree as $id => $item) { // Only work with enabled links if (empty($item['link']['hidden'])) { $class = ''; // add active-trail if ($item['link']['in_active_trail']) { $class = ' active-trail '; } // add class based on link title $classtwo = megatron_id_safe($item['link']['title']); $new_item = array('title' => $item['link']['title'], 'link_path' => $item['link']['link_path'], 'href' => $item['link']['href']); // Don't use levels deeper than 1 if ($lvl < 1) { $new_item['below'] = megatron_menu_navigation_links($item['below'], $lvl + 1); } $result['menu-' . $item['link']['mlid'] . $class . ' ' . $classtwo] = $new_item; } } } return $result; }