function _econ_get_menu_children($path) { $parent = menu_link_get_preferred($path); $parameters = array('conditions' => array('plid' => $parent['mlid'])); $children = menu_build_tree($parent['menu_name'], $parameters); return array_values($children); }
/** * Wrapper around menu_build_tree that runs i18n over it when available. */ function _openomega_menu_build_tree($menu_name, $parameters = array()) { $tree = menu_build_tree($menu_name, $parameters); if (function_exists('i18n_menu_localize_tree')) { $tree = i18n_menu_localize_tree($tree); } return $tree; }
/** * Formats the menu links for the child pages of the current page. * * @param array $book_link * A fully loaded menu link that is part of the book hierarchy. * * @return string * HTML for the links to the child pages of the current page. */ function _bootstrap_book_children($book_link) { // Rebuild entire menu tree for the book. $tree = menu_build_tree($book_link['menu_name']); $tree = menu_tree_output($tree); // Fix the theme hook suggestions. _bootstrap_book_fix_theme_hooks($book_link['nid'], $tree); // Return the rendered output. return drupal_render($tree); }
/** * Genereate navbar menu. */ function valghalla_bs_theme_navbarmenu($path) { $parent = menu_link_get_preferred($path); $parameters = array('active_trail' => array($parent['plid']), 'only_active_trail' => FALSE, 'min_depth' => $parent['depth'] + 1, 'max_depth' => $parent['depth'] + 1, 'conditions' => array('plid' => $parent['mlid'])); $children = menu_build_tree($parent['menu_name'], $parameters); $tree_output = menu_tree_output($children); $items = array(); foreach ($tree_output as $item_id => $item_data) { if (is_numeric($item_id) && is_array($item_data)) { $items[] = l($item_data['#title'], $item_data['#href'], array('attributes' => $item_data['#attributes'], 'html' => TRUE)); } } $menu = theme('item_list', array('items' => $items, 'type' => 'ul', 'attributes' => array('class' => 'dropdown-menu'))); $toggle = '<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . $parent['link_title'] . ' <b class="caret"></b></a>'; if ($menu) { return $toggle . $menu; } }
/** * Implements template_preprocess_page(). */ function sizzle_preprocess_page(&$variables) { $theme_path = drupal_get_path('theme', 'sizzle'); // Add a menu link. $variables['menu_link'] = l(t('The Menu'), 'menus', array('attributes' => array('class' => array('btn')))); // Add a reservation link. $variables['reservation_link'] = ''; if (module_exists('restaurant_reservation')) { $variables['reservation_link'] = l(t('Book a Table'), 'reservation', array('attributes' => array('class' => array('btn')))); } // Add the footer menu to the template. $show_footer_nav = theme_get_setting('show_footer_nav'); if ($show_footer_nav) { $footer_nav_data = menu_build_tree('menu-footer-menu', array('min_depth' => 1, 'max_depth' => 2)); $variables['footer_nav'] = menu_tree_output($footer_nav_data); $variables['footer_nav']['#theme_wrappers'] = array(); } // Add the site background image. if ($site_background_image_fid = theme_get_setting('site_background_image')) { $site_background_image = file_load($site_background_image_fid); $site_background_image_url = file_create_url($site_background_image->uri); drupal_add_css('body { background-image: url("' . $site_background_image_url . '") }', array('type' => 'inline')); } // Add the footer background image. if ($footer_background_image_fid = theme_get_setting('footer_background_image')) { $footer_background_image = file_load($footer_background_image_fid); $footer_background_image_url = file_create_url($footer_background_image->uri); } else { $footer_background_image_url = '/' . $theme_path . '/assets/images/bg/bg-footer-default.jpg'; } drupal_add_css('.footer { background-image: url("' . $footer_background_image_url . '") }', array('type' => 'inline')); // Add copyright to theme. $copyright = theme_get_setting('copyright'); $variables['copyright'] = check_markup($copyright['value'], $copyright['format']); // Add footer text. $footer_text = theme_get_setting('footer_text'); $variables['footer_text'] = check_markup($footer_text['value'], $footer_text['format']); $variables['address'] = panopoly_config_get('address'); $variables['phone'] = panopoly_config_get('phone'); $variables['opening_hours'] = panopoly_config_get('opening_hours'); }
function footmali_preprocess_page(&$variables) { if (isset($variables['main_menu'])) { $menu_tree_array = menu_build_tree('main-menu'); $main_links = ''; foreach ($menu_tree_array as $menu) { $main_links .= '<li><a href="' . url($menu['link']['link_path']) . '"><span>' . $menu['link']['link_title'] . '</span></a>'; if (count($menu['below']) > 0) { $main_links .= '<ul class="sub-menu">'; foreach ($menu['below'] as $sub_menu) { $main_links .= '<li><a href="/' . drupal_get_path_alias($sub_menu['link']['link_path']) . '">' . $sub_menu['link']['link_title'] . '</a></li>'; } $main_links .= '</ul>'; } $main_links .= '</li>'; } $variables['main_links'] = $main_links; } $search_block = module_invoke('search', 'block_view', 'search'); $variables['search_block'] = $search_block; }
foreach ($childrens as $children) { $path = $children["link"]["link_path"]; $parent = menu_link_get_preferred($path); $parameters = array('active_trail' => array($parent['plid']), 'only_active_trail' => FALSE, 'min_depth' => $parent['depth'] + 1, 'max_depth' => $parent['depth'] + 1, 'conditions' => array('plid' => $parent['mlid'])); $childrens2 = menu_build_tree($parent['menu_name'], $parameters); echo '<li class="nb' . $children["link"]["mlid"] . '">'; $nbChildrens = count($childrens2); if ($nbChildrens > 0) { echo '<a href="#r' . $children["link"]["mlid"] . '">' . $children["link"]["title"] . '<i class="pull-right fa fa-angle-right"></i></a>'; echo '<div class="menu row" id="r' . $children["link"]["mlid"] . '">'; echo '<ul class="level3">'; foreach ($childrens2 as $children2) { $path = $children2["link"]["link_path"]; $parent = menu_link_get_preferred($path); $parameters = array('active_trail' => array($parent['plid']), 'only_active_trail' => FALSE, 'min_depth' => $parent['depth'] + 1, 'max_depth' => $parent['depth'] + 1, 'conditions' => array('plid' => $parent['mlid'])); $childrens3 = menu_build_tree($parent['menu_name'], $parameters); echo '<li class="nb' . $children2["link"]["mlid"] . '">'; $nbChildrens = count($childrens3); if ($nbChildrens > 0) { echo '<a href="#r' . $children2["link"]["mlid"] . '">' . $children2["link"]["title"] . '</a>'; echo '<div class="menu row" id="r' . $children2["link"]["mlid"] . '">'; echo '<ul class="level4">'; foreach ($childrens3 as $children3) { $path = $children3["link"]["link_path"]; $parent = menu_link_get_preferred($path); $parameters = array('active_trail' => array($parent['plid']), 'only_active_trail' => FALSE, 'min_depth' => $parent['depth'] + 1, 'max_depth' => $parent['depth'] + 1, 'conditions' => array('plid' => $parent['mlid'])); echo '<li class="nb' . $children3["link"]["mlid"] . '">'; $alias = drupal_get_path_alias($path); echo '<a href="/drupal7/' . $alias . '">' . $children3["link"]["title"] . '</a>'; echo '</li>'; }
/** * Render * * Renders the menu with the configuration options passed to * the class. * * @return string The rendered menu. */ public function render() { $menu_tree_options = array(); $menu_tree_options['max_depth'] = $this->depth; $menu_tree_options['active_trail'] = menu_get_active_trail(); if (!$this->expand_all) { $parents = array(); foreach (menu_get_active_trail() as $menu_item) { if (!array_key_exists('mlid', $menu_item)) { continue; } $parents[$menu_item['mlid']] = $menu_item['mlid']; } $menu_tree_options['expanded'] = $parents; } if ($this->parent) { $parent_link = menu_link_load($this->parent); $menu_tree_options['active_trail'] = array($parent_link['mlid']); $menu_tree_options['only_active_trail'] = false; $menu_tree_options['min_depth'] = $parent_link['depth'] + 1; $menu_tree_options['conditions'] = array("p{$parent_link['depth']}" => $parent_link['mlid']); } $menu_tree = array(); if ($this->include_parent_as_first && isset($parent_link)) { $menu_tree = menu_build_tree($this->menu['menu_name'], array('conditions' => array('mlid' => $parent_link['mlid']))); } $menu_tree_no_parent = menu_build_tree($this->menu['menu_name'], $menu_tree_options); $menu_tree += $menu_tree_no_parent; // Now prepare the output. $output = menu_tree_output($menu_tree); // Prepare the active link classes. $output_no_parent = menu_tree_output($menu_tree_no_parent); $this->addActiveTrailClasses($output_no_parent); $output = array_replace_recursive($output, $output_no_parent); // Now add the themes to the output. $this->addLinkThemes($output); // Continue preparing the output. $output['#theme_wrappers'] = array('ablecore_menu_tree'); if ($this->menu_theme) { $output['#theme_wrappers'][] = $this->menu_theme; } $attributes = array(); if (!is_array($this->classes)) { $this->classes = array('menu'); } if (array_search('menu', $this->classes) === false) { $this->classes[] = 'menu'; } $attributes['class'] = implode(' ', $this->classes); if ($this->id) { $attributes['id'] = $this->id; } if (count($attributes) > 0) { $output['#attributes'] = $attributes; } return render($output); }
/** * Implements template_preprocess_page(). */ function radix_preprocess_page(&$variables) { // Determine if the page is rendered using panels. $variables['is_panel'] = FALSE; if (module_exists('page_manager') && count(page_manager_get_current_page())) { $variables['is_panel'] = TRUE; } // Make sure tabs is empty. if (empty($variables['tabs']['#primary']) && empty($variables['tabs']['#secondary'])) { $variables['tabs'] = ''; } // Theme action links as buttons. if (!empty($variables['action_links'])) { foreach (element_children($variables['action_links']) as $key) { $variables['action_links'][$key]['#link']['localized_options']['attributes'] = array('class' => array('btn', 'btn-primary', 'btn-sm')); } } // Add search_form to theme. $variables['search_form'] = ''; if (module_exists('search') && user_access('search content')) { $search_box_form = drupal_get_form('search_form'); $search_box_form['basic']['keys']['#title'] = 'Search'; $search_box_form['basic']['keys']['#title_display'] = 'invisible'; $search_box_form['basic']['keys']['#size'] = 20; $search_box_form['basic']['keys']['#attributes'] = array('placeholder' => 'Search'); $search_box_form['basic']['keys']['#attributes']['class'][] = 'form-control'; $search_box_form['basic']['submit']['#value'] = t('Search'); $search_box_form['#attributes']['class'][] = 'navbar-form'; $search_box_form['#attributes']['class'][] = 'navbar-right'; $search_box = drupal_render($search_box_form); $variables['search_form'] = user_access('search content') ? $search_box : NULL; } // Format and add main menu to theme. $main_menu_data = menu_build_tree(variable_get('menu_main_links_source', 'main-menu'), array('min_depth' => 1, 'max_depth' => 2)); $variables['main_menu'] = menu_tree_output($main_menu_data); $variables['main_menu']['#theme_wrappers'] = array(); // Add a copyright message. $variables['copyright'] = t('Drupal is a registered trademark of Dries Buytaert.'); // Display a message if Sass has not been compiled. // $theme_path = drupal_get_path('theme', $GLOBALS['theme']); // $stylesheet_path = $theme_path . '/assets/stylesheets/screen.css'; // if (_radix_current_theme() == 'radix') { // $stylesheet_path = $theme_path . '/assets/stylesheets/radix-style.css'; // } // if (!file_exists($stylesheet_path)) { // drupal_set_message(t('It looks like %path has not been created yet. Run <code>@command</code> in your theme directory to create it.', array( // '%path' => $stylesheet_path, // '@command' => 'compass watch', // )), 'error'); // } }
<?php global $theme_path; global $base_url; global $language; $shortcuts = menu_build_tree("menu-shortcatmenu"); //$shortcuts = i18n_menu_localize_tree($shortcuts); $mainmenu = econ_pages_submenu_tree_all_data(0, $menu = "menu-econ-mainmenu"); print _econ_pages_menu_block_view("menu_mobile_block"); ?> <div id="wrapper" class="wrapper"> <header class="header"> <div class="container"> <div class="row"> <!--[if lt IE 8]> <p class="browserupgrade">Вы используете слишком <strong>старый</strong> браузер. Пожалуйста <a href="http://browsehappy.com/">смените его</a> и все станет красиво.</p> <![endif]--> <div class="header-spbgu col-xs-3 col-sm-2"> <div class="header-spbgu__slide"> <div class="header-spbgu__frontside"> <div class="header-spbgu__gerb"> <?php include DRUPAL_ROOT . "/" . $theme_path . '/spbgu/app/img/common/gerb.svg'; ?> </div> <div class="header-spbgu__title"> <span class="visible-xs visible-sm">СПБГУ</span> <span class="hidden-xs hidden-sm">САНКТ-ПЕТЕРБУРГСКИЙ<br>ГОСУДАРСТВЕННЫЙ<br> УНИВЕРСИТЕТ</span> </div> </div> <a href="http://spbu.ru" class="header-spbgu__backside">
/** * Local function * * Builds a sidebar menu based on the current path. * * @return HTML content or false * * @todo Refactor */ function _uw_boundless_uw_sidebar_menu() { global $theme; // check the theme setting for visibility if (!theme_get_setting('uw_boundless_sidebar_menu_visibility')) { return FALSE; } // get some data $current_path = current_path(); $active_trail = menu_get_active_trail(); $current_depth = count($active_trail); $active_trail_key = $current_depth - 1; // no trail, no sidebar menu if ($active_trail_key < 1) { return FALSE; } // prevent admin paths from building the sidebar menu if (path_is_admin($current_path)) { return FALSE; } // is menu_name a key in the active trail if (!array_key_exists('menu_name', $active_trail[1])) { return FALSE; } // don't build the sidebar if menu_name is not the main-menu if (!$active_trail[1]['menu_name'] == 'main-menu') { $_message = 'I\'m sorry, there\'s an issue with the sidebar menu. I can\'t build it. The active trail of this page does not appear to be the main-menu. It looks like it\'s using menu "' . $active_trail[1]['menu_name'] . '".'; drupal_set_message($_message, 'warning'); // write to log watchdog_exception($theme, new Exception($_message)); return FALSE; } // get the current menu link $current_link = menu_link_get_preferred($current_path, 'main-menu'); $output = TRUE; $output_menu = ''; $output_menu .= '<ul>'; // only display sidebar menu when there's a parent and it's not hidden if (isset($current_link['plid']) && !$current_link['hidden']) { // first level links if ($current_depth == 2 && $current_link['has_children']) { // show sub tree of current node $output_menu .= '<li class="page_item page_item_has_children current_page_item">'; $output_menu .= l($current_link['link_title'], $current_link['link_path']); // parameters to build the tree $parameters = array('active_trail' => array($current_link['plid']), 'only_active_trail' => FALSE, 'min_depth' => $current_link['depth'] + 1, 'max_depth' => $current_link['depth'] + 1, 'conditions' => array('plid' => $current_link['mlid'])); // get the children $children = menu_build_tree($current_link['menu_name'], $parameters); $output_menu .= '<ul class="children">'; foreach ($children as $child) { if (!$child['link']['hidden']) { $output_menu .= '<li class="page_item">'; $output_menu .= l($child['link']['link_title'], $child['link']['link_path']); $output_menu .= '</li>'; } } $output_menu .= '</ul>'; $output_menu .= '</li>'; } elseif ($current_depth > 2) { // show sub tree of parent and // display current node as current page item // get active parent by moving one up the trail $active_parent = $active_trail[$active_trail_key - 1]; // create flag if parent points home $active_parent_is_front = $active_parent['link_path'] === '<front>' ? TRUE : FALSE; // get the parent menu link $parent_link = menu_link_get_preferred($active_parent['link_path'], 'main-menu'); // however, if active parent points home, create a new array // using front as path if ($active_parent_is_front) { $parent_link = array('link_title' => $active_parent['link_title'], 'link_path' => '<front>', 'plid' => $active_parent['plid'], 'mlid' => $active_parent['mlid'], 'menu_name' => $active_parent['menu_name'], 'depth' => $active_parent['depth']); } $output_menu .= '<li class="page_item page_item_has_children current_page_ancestor current_page_parent">'; $output_menu .= l($parent_link['link_title'], $parent_link['link_path']); // parameters to build the tree $parameters = array('active_trail' => array($parent_link['plid']), 'only_active_trail' => FALSE, 'min_depth' => $parent_link['depth'] + 1, 'max_depth' => $parent_link['depth'] + 1, 'conditions' => array('plid' => $parent_link['mlid'])); // get the children $children = menu_build_tree($parent_link['menu_name'], $parameters); $output_menu .= '<ul class="children">'; foreach ($children as $child) { if (!$child['link']['hidden']) { if ($current_path == $child['link']['link_path']) { $output_menu .= '<li class="page_item current_page_item">'; $output_menu .= '<span>' . $child['link']['link_title'] . '</span>'; if ($child['link']['has_children']) { // get the grandchildren // parameters to build the tree $parameters = array('active_trail' => array($child['link']['plid']), 'only_active_trail' => FALSE, 'min_depth' => $child['link']['depth'] + 1, 'max_depth' => $child['link']['depth'] + 1, 'conditions' => array('plid' => $child['link']['mlid'])); $grandchildren = menu_build_tree($child['link']['menu_name'], $parameters); $output_menu .= '<ul class="children">'; foreach ($grandchildren as $grandchild) { if (!$grandchild['link']['hidden']) { $output_menu .= '<li class="page_item">'; $output_menu .= l($grandchild['link']['link_title'], $grandchild['link']['link_path']); $output_menu .= '</li>'; } } $output_menu .= '</ul>'; } } else { $output_menu .= '<li class="page_item">'; $output_menu .= l($child['link']['link_title'], $child['link']['link_path']); } $output_menu .= '</li>'; } } $output_menu .= '</ul>'; $output_menu .= '</li>'; } else { // link has no children $output = FALSE; } } else { $output = FALSE; } $output_menu .= '</ul>'; return $output ? $output_menu : $output; }
function _sidebar_menu() { $parent = menu_link_get_preferred($_GET['q']); $parameters = array('active_trail' => array($parent['plid']), 'only_active_trail' => FALSE, 'min_depth' => $parent['depth'] + 1, 'max_depth' => $parent['depth'] + 1, 'conditions' => array('plid' => $parent['mlid'])); $children = menu_build_tree($parent['menu_name'], $parameters); return '<ul class="sidebar-menu">' . _process_child_menu_node($children) . '</ul>'; }
<?php $menu_tree = menu_build_tree('main-menu', array('min_depth' => 1, 'max_depth' => 2)); $to_output = array(); if (!empty($menu_tree)) { foreach ($menu_tree as $item) { if (strtolower($item['link']['link_title']) == 'home') { continue; } $children = array(); if (!empty($item['below'])) { foreach ($item['below'] as $item_below) { $children[] = array('link_to' => url($item_below['link']['link_path']), 'link_text' => $item_below['link']['link_title']); } } $to_output[] = array('link_to' => url($item['link']['link_path']), 'link_text' => $item['link']['link_title'], 'children' => $children); } } function _render_footer_menu_partial($menu, $i) { if (empty($menu[$i])) { return; } $menu_partial = $menu[$i]; echo '<a class="footer-nav-header" href="' . $menu_partial['link_to'] . '"><strong>' . $menu_partial['link_text'] . '</strong></a>'; echo '<ul>'; foreach ($menu_partial['children'] as $item) { echo '<li>'; echo '<a href="' . $item['link_to'] . '">' . $item['link_text'] . '</a>'; echo '</li>'; }