function title_internal() { return menu_get_active_trail(); $arr[0] = $class[1]['title']; $arr[1] = $class[1]['href']; return $arr; }
/** * Set the title to the active site section * * @return the title to use for the current page */ function nateswart_get_display_title() { $retval = ''; $trail = menu_get_active_trail(); if (isset($trail[1]['link_title'])) { $retval = $trail[1]['link_title']; } return $retval; }
function corporato_preprocess_page(&$variables) { $main_menu_tree = menu_tree_all_data('main-menu'); //$expanded = menu_tree_output($main_menu_tree); //krumo($main_menu_tree); //krumo($expanded); $menuParent = array_slice(menu_get_active_trail(), 1); //krumo($menuParent); $output = '<ul>' . _process_menu_node($main_menu_tree, $menuParent) . '</ul>'; //krumo($output); //krumo($expanded); $variables['corporato_main_menu'] = $output; }
/** * Implements hook_preprocess_region(). */ function spartan_preprocess_region(&$vars) { global $language; switch ($vars['region']) { // Menu region. case 'menu': $footer_menu_cache = cache_get("footer_menu_data:" . $language->language); if ($footer_menu_cache) { $footer_menu = $footer_menu_cache->data; } else { $footer_menu = menu_tree_output(_spartan_menu_build_tree('main-menu', array('max_depth' => 2))); cache_set("footer_menu_data:" . $language->language, $footer_menu); } //set the active trail $active_trail = menu_get_active_trail(); foreach ($active_trail as $trail) { if (isset($trail['mlid']) && isset($footer_menu[$trail['mlid']])) { $footer_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail'; } } $vars['dropdown_menu'] = $footer_menu; break; // Default footer content. // Default footer content. case 'footer_first': $footer_menu_cache = cache_get("footer_menu_data:" . $language->language); if ($footer_menu_cache) { $footer_menu = $footer_menu_cache->data; } else { $footer_menu = menu_tree_output(_spartan_menu_build_tree('main-menu', array('max_depth' => 2))); cache_set("footer_menu_data:" . $language->language, $footer_menu); } //set the active trail $active_trail = menu_get_active_trail(); foreach ($active_trail as $trail) { if (isset($trail['mlid']) && isset($footer_menu[$trail['mlid']])) { $footer_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail'; } } $vars['footer_menu'] = $footer_menu; $vars['site_name'] = $site_name = variable_get('site_name'); $vars['footer_logo'] = l(theme('image', array('path' => drupal_get_path('theme', 'spartan') . "/logo-sm.png", 'alt' => "{$site_name} logo")), '', array("html" => TRUE, 'attributes' => array('class' => 'logo'))); if (function_exists('defaultcontent_get_node') && ($node = defaultcontent_get_node("email_update"))) { $node = node_view($node); $vars['subscribe_form'] = $node['webform']; } //krumo($vars['footer_menu']); break; } }
/** * Implements hook_preprocess_region(). */ function openomega_preprocess_region(&$vars) { global $language; switch ($vars['region']) { // menu region case 'menu': $dropdown_menu = menu_tree_output(_openomega_menu_build_tree('main-menu', array('max_depth' => 2))); //set the active trail $active_trail = menu_get_active_trail(); foreach ($active_trail as $trail) { if (isset($trail['mlid']) && isset($dropdown_menu[$trail['mlid']])) { $dropdown_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail'; } } // Set the tab index for those with drop downs so can access the links. foreach ($dropdown_menu as $key => $item) { if (!empty($dropdown_menu[$key]['#below'])) { $dropdown_menu[$key]['#attributes']['tabindex'] = 0; } } $vars['dropdown_menu'] = $dropdown_menu; break; // default footer content // default footer content case 'footer_first': $footer_menu = menu_tree_output(_openomega_menu_build_tree('main-menu', array('max_depth' => 2))); //set the active trail $active_trail = menu_get_active_trail(); foreach ($active_trail as $trail) { if (isset($trail['mlid']) && isset($footer_menu[$trail['mlid']])) { $footer_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail'; } } $vars['footer_menu'] = $footer_menu; $vars['site_name'] = $site_name = variable_get('site_name'); $vars['footer_logo'] = l(theme('image', array('path' => drupal_get_path('theme', 'openomega') . "/logo-sm.png", 'alt' => "{$site_name} logo")), '', array("html" => TRUE, 'attributes' => array('class' => 'logo'))); if (function_exists('defaultcontent_get_node') && ($node = defaultcontent_get_node("email_update"))) { $node = node_view($node); $vars['subscribe_form'] = $node['webform']; } break; } }
/** * Implements theme_links__system_main_menu. */ function innovation_links__system_main_menu($variables) { $links = $variables['links']; $attributes = $variables['attributes']; $heading = $variables['heading']; $trail = menu_get_active_trail(); array_shift($trail); unset($links['#sorted']); unset($links['#theme_wrappers']); global $language_url; $output = ''; if (count($links) > 0) { $output = ''; // Treat the heading first if it is present to prepend it to the // list of links. if (!empty($heading)) { if (is_string($heading)) { // Prepare the array that will be used when the passed heading // is a string. $heading = array('text' => $heading, 'level' => 'h2'); } $output .= '<' . $heading['level']; if (!empty($heading['class'])) { $output .= drupal_attributes(array('class' => $heading['class'])); } $output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>'; } $output .= '<ul' . drupal_attributes($attributes) . '>'; $num_links = count($links); $i = 1; foreach ($links as $key => $link) { $class = array($key); $link['#attributes'] = isset($link['#localized_options']['attributes']) ? $link['#localized_options']['attributes'] : array(); // Add first/last/active classes to help out themers. if ($i == 1) { $class[] = 'first'; } if ($i == $num_links) { $class[] = 'last'; } if (isset($link['#href']) && ($link['#href'] == $_GET['q'] || $link['#href'] == '<front>' && drupal_is_front_page()) && (empty($link['#language']) || $link['#language']->language == $language_url->language)) { $class[] = 'active'; } // Check for, and honor active states set by context menu reactions if (module_exists('context')) { $contexts = context_active_contexts(); foreach ($contexts as $context) { if (isset($context->reactions['menu'])) { if ($link['#href'] == $context->reactions['menu']) { $class[] = 'active'; } } } } $options['attributes'] = $link['#attributes']; // Make list item a dropdown if we have child items. if (!empty($link['#below'])) { $class[] = 'dropdown'; $class[] = 'clearfix'; } if (!empty($trail) && isset($trail[0]['mlid']) && $link['#original_link']['mlid'] == $trail[0]['mlid']) { $class[] = 'active'; } $output .= '<li' . drupal_attributes(array('class' => $class)) . '>'; if (isset($link['#href'])) { // Pass in $link as $options, they share the same keys. $output .= l($link['#title'], $link['#href'], array('attributes' => $link['#attributes'])); } elseif (!empty($link['#title'])) { // Wrap non-<a> links in <span> for adding title and class attributes. if (empty($link['#html'])) { $link['#title'] = check_plain($link['#title']); } $span_attributes = ''; if (isset($link['#attributes'])) { $span_attributes = drupal_attributes($link['#attributes']); } $output .= '<span' . $span_attributes . '>' . $link['#title'] . '</span>'; } // If link has child items, print a toggle and dropdown menu. if (!empty($link['#below'])) { $dropdown_id = 'main-menu-dropdown-' . $i; $output .= '<a href="#" class="dropdown-toggle pull-right" data-toggle="dropdown" id="' . $dropdown_id . '"><span class="caret"></span></a>'; $output .= theme('links__system_main_menu', array('links' => $link['#below'], 'attributes' => array('class' => array('dropdown-menu'), 'role' => 'menu', 'aria-labelledby' => $dropdown_id))); } $i++; $output .= "</li>\n"; } $output .= '</ul>'; } return $output; }
* @see adaptivetheme_process_node() */ /** * Hide Content and Print it Separately * * Use the hide() function to hide fields and other content, you can render it * later using the render() function. Install the Devel module and use * <?php dsm($content); ?> to find variable names to hide() or render(). */ hide($content['comments']); hide($content['links']); ?> <?php // $trail_blanco = array(); $trail_blanco = menu_get_active_trail(); //print_r($trail_blanco); ?> <?php // print $trail_blanco[1][link_title]; ?> <?php // print $trail_blanco[1][link_path]; ?> <?php // print $trail_blanco[2][link_title]; ?>
/** * Set LC breadcrumbs * * @return void */ protected function setBreadcrumbs() { $widget = $this->getHandler()->getWidget('\\XLite\\View\\Location'); $lcNodes = array_map(function (\XLite\View\Location\Node $node) { return $node->getContent(); }, $widget->getNodes()); array_shift($lcNodes); // Add store root node $trails = menu_get_active_trail(); array_splice($trails, 1, 0, array(array('title' => t('Store'), 'href' => \XLite\Core\Converter::buildFullURL(), 'link_path' => '', 'localized_options' => array(), 'type' => MENU_VISIBLE_IN_BREADCRUMB))); menu_set_active_trail($trails); $drupalNodes = array_slice(drupal_get_breadcrumb(), 0, 2); drupal_set_breadcrumb(array_merge($drupalNodes, $lcNodes)); }
function get_title_data() { $navigation_vocab = 'taxanavigation'; $trail = menu_get_active_trail(); $taxon = taxonomy_get_term_by_name($trail[2]['title'], $navigation_vocab); reset($taxon); return current($taxon); }
/** * 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; }
/** * Implements hook_alpha_preprocess_block() * * There is an issue with using Path Breadcrumb module with Delta blocks. * See drupal.org/node/1777644 for description of issue and fix. */ function vp_theme_alpha_preprocess_block(&$vars) { if ($vars['block']->module == 'delta_blocks' && $vars['block']->delta == 'breadcrumb') { $data = array('#theme' => 'breadcrumb', '#breadcrumb' => drupal_get_breadcrumb()); $last = $data['#breadcrumb'][count($data['#breadcrumb']) - 1]; if (!empty($last) && strpos($last, '<a') === FALSE && strlen($last) > 50) { $data['#breadcrumb'][count($data['#breadcrumb']) - 1] = substr($data['#breadcrumb'][count($data['#breadcrumb']) - 1], 0, 50) . '...'; } $active_trail = array(); $obj = menu_get_object('node'); if ($obj && $obj->type === 'article') { $trail = menu_get_active_trail(); unset($trail[count($trail) - 1]); foreach ($trail as $menu_item) { $active_trail[] = l($menu_item['title'], $menu_item['href']); } $active_trail[] = $data['#breadcrumb'][count($data['#breadcrumb']) - 1]; $data['#breadcrumb'] = $active_trail; } $breadcrumb = render($data); $vars['content'] = $breadcrumb; } }
/** * Implementation of preprocess_page(). */ function bootstrap_preprocess_page(&$vars, $hook) { if (!module_exists('conditional_styles')) { $vars['styles'] .= $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], ''); } // Update jQuery if (arg(0) != 'admin') { $scripts = drupal_add_js(); // Use Google for jQuery $vars['head'] .= '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>'; unset($scripts['core']['misc/jquery.js']); $vars['scripts'] = drupal_get_js('header', $scripts); } // Unset css $css = drupal_add_css(); unset($css['all']['module']['modules/node/node.css']); //unset($css['all']['module']['modules/system/system.css']); unset($css['all']['module']['modules/system/defaults.css']); unset($css['all']['module']['modules/system/system-menus.css']); unset($css['all']['module']['modules/user/user.css']); $vars['styles'] = drupal_get_css($css); // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) $classes = split(' ', $vars['body_classes']); // Remove the mostly useless page-ARG0 class. if ($index = array_search(preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-' . drupal_strtolower(arg(0))), $classes)) { unset($classes[$index]); } if (!$vars['is_front']) { // Add unique class for each page. $path = drupal_get_path_alias($_GET['q']); $classes[] = bootstrap_id_safe('page-' . $path); if (arg(0) == 'node') { if (arg(1) == 'add') { $section = 'node-add'; $classes[] = bootstrap_id_safe('section-' . $section); } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) { $section = 'node-' . arg(2); $classes[] = bootstrap_id_safe('section-' . $section); } } // Add unique class for each website section. $sections = explode('/', $path); for ($i = 0; $i < count($sections); $i++) { $count = 0; $class = 'section-'; for ($count; $count <= $i; $count++) { $class .= $sections[$count]; if ($count < $i) { $class .= '-'; } } $classes[] = bootstrap_id_safe($class); } } $vars['body_classes_array'] = $classes; $vars['body_classes'] = implode(' ', $classes); // Concatenate with spaces. // Theme form variables $vars['mobile_breadcrumb_btn_text'] = theme_get_setting('mobile_breadcrumb_btn_text'); $vars['mobile_offcanvas_btn_text'] = theme_get_setting('mobile_offcanvas_btn_text'); // Theme form variables $layout_front_offcanvas_sidebar = theme_get_setting('layout_front_offcanvas_sidebar'); $vars['layout_front_display_page_title'] = theme_get_setting('layout_front_display_page_title'); $vars['layout_front_display_page_content'] = theme_get_setting('layout_front_display_page_content'); $vars['layout_front_offcanvas_sidebar'] = $layout_front_offcanvas_sidebar; // Create column classes if ($vars['left'] && $vars['right'] && $vars['is_front'] && $layout_front_offcanvas_sidebar == TRUE) { $vars['css_main'] = ' class="row"'; $vars['css_content'] = ' class="col-xs-12 col-sm-8 col-md-6 col-lg-6 col-md-push-3 col-lg-push-3"'; $vars['css_right'] = ' class="col-xs-12 col-sm-4 col-md-3 col-lg-3 col-md-push-3 col-lg-push-3"'; $vars['css_left'] = ' class="col-xs-6 col-sm-12 col-md-3 col-lg-3 col-md-pull-9 col-lg-pull-9"'; } elseif ($vars['left'] && $vars['is_front'] && $layout_front_offcanvas_sidebar == TRUE) { $vars['css_main'] = ' class="row"'; $vars['css_content'] = ' class="col-xs-12 col-sm-9 col-md-9 col-lg-9 col-sm-push-3 col-md-push-3 col-lg-push-3"'; $vars['css_right'] = ''; $vars['css_left'] = ' class="col-xs-12 col-sm-3 col-md-3 col-lg-3 col-sm-pull-9 col-md-pull-9 col-lg-pull-9"'; } elseif ($vars['left'] && $vars['right']) { $vars['css_main'] = ' class="row row-offcanvas row-offcanvas-left"'; $vars['css_content'] = ' class="col-xs-12 col-sm-8 col-md-6 col-lg-6 col-md-push-3 col-lg-push-3"'; $vars['css_right'] = ' class="col-xs-12 col-sm-4 col-md-3 col-lg-3 col-md-push-3 col-lg-push-3"'; $vars['css_left'] = ' class="col-xs-6 col-sm-12 col-md-3 col-lg-3 col-md-pull-9 col-lg-pull-9 sidebar-offcanvas"'; } elseif ($vars['left']) { $vars['css_main'] = ' class="row row-offcanvas row-offcanvas-left"'; $vars['css_content'] = ' class="col-xs-12 col-sm-9 col-md-9 col-lg-9 col-sm-push-3 col-md-push-3 col-lg-push-3"'; $vars['css_right'] = ''; $vars['css_left'] = ' class="col-xs-6 col-sm-3 col-md-3 col-lg-3 col-sm-pull-9 col-md-pull-9 col-lg-pull-9 sidebar-offcanvas"'; } elseif ($vars['right']) { $vars['css_main'] = ' class="row"'; $vars['css_content'] = ' class="col-xs-12 col-sm-9 col-md-9 col-lg-9"'; $vars['css_right'] = ' class="col-xs-12 col-sm-3 col-md-3 col-lg-3"'; $vars['css_left'] = ''; } // Theme form variables $mobile_nav_bg = theme_get_setting('mobile_nav_bg'); $mobile_logo_use = theme_get_setting('mobile_logo_use'); $mobile_logo_path = theme_get_setting('mobile_logo_path'); // Mobile nav bg color override if ($mobile_nav_bg != '') { $vars['mobile_nav_bg'] = ' style="background-color:' . $mobile_nav_bg . '"'; } if ($mobile_logo_use == TRUE) { $vars['mobile_logo'] = TRUE; $vars['mobile_logo_path'] = $mobile_logo_path; } // Theme form variables $bootstrap_touch_icon_default_path = theme_get_setting('bootstrap_touch_icon_default_path'); $bootstrap_touch_icon_default_use = theme_get_setting('bootstrap_touch_icon_default_use'); $bootstrap_touch_icon_ipad_path = theme_get_setting('bootstrap_touch_icon_ipad_path'); $bootstrap_touch_icon_ipad_use = theme_get_setting('bootstrap_touch_icon_ipad_use'); $bootstrap_touch_icon_iphone_r_path = theme_get_setting('bootstrap_touch_icon_iphone_r_path'); $bootstrap_touch_icon_iphone_r_use = theme_get_setting('bootstrap_touch_icon_iphone_r_use'); $bootstrap_touch_icon_ipad_r_path = theme_get_setting('bootstrap_touch_icon_ipad_r_path'); $bootstrap_touch_icon_ipad_r_use = theme_get_setting('bootstrap_touch_icon_ipad_r_use'); $bootstrap_touch_icon_windows_metro_path = theme_get_setting('bootstrap_touch_icon_windows_metro_path'); $bootstrap_touch_icon_windows_metro_use = theme_get_setting('bootstrap_touch_icon_windows_metro_use'); $bootstrap_touch_icon_windows_metro_color = theme_get_setting('bootstrap_touch_icon_windows_metro_color'); // Touch icons $bootstrap_touch_icons = ''; if (!empty($bootstrap_touch_icon_default_path) && $bootstrap_touch_icon_default_use == true) { $bootstrap_touch_icons .= '<link rel="apple-touch-icon-precomposed" href="/' . $bootstrap_touch_icon_default_path . '" />'; } if (!empty($bootstrap_touch_icon_ipad_path) && $bootstrap_touch_icon_ipad_use == true) { $bootstrap_touch_icons .= '<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/' . $bootstrap_touch_icon_ipad_path . '" />'; } if (!empty($bootstrap_touch_icon_iphone_r_path) && $bootstrap_touch_icon_iphone_r_use == true) { $bootstrap_touch_icons .= '<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/' . $bootstrap_touch_icon_iphone_r_path . '" />'; } if (!empty($bootstrap_touch_icon_ipad_r_path) && $bootstrap_touch_icon_ipad_r_use == true) { $bootstrap_touch_icons .= '<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/' . $bootstrap_touch_icon_ipad_r_path . '" />'; } if (!empty($bootstrap_touch_icon_windows_metro_path) && !empty($bootstrap_touch_icon_windows_metro_color) && $bootstrap_touch_icon_windows_metro_use == true) { $bootstrap_touch_icons .= '<meta name="msapplication-TileImage" content="' . $bootstrap_touch_icon_windows_metro_path . '" />'; $bootstrap_touch_icons .= '<meta name="msapplication-TileColor" content="#' . $bootstrap_touch_icon_windows_metro_color . '" />'; } $vars['bootstrap_touch_icons'] = $bootstrap_touch_icons; $active_trail = menu_get_active_trail(); end($active_trail); $parent = prev($active_trail); if ($parent['title'] != 'Home') { $vars['section_title'] = $parent['link_title']; } else { $vars['section_title'] = $vars['title']; } bootstrap_contact_buttons($vars); }
/** * Current Link * * Gets the menu link representing the current page (if one exists). * * @return array The menu link. */ public static function current_link() { $link = false; // Check with ablecore_menu first. if (module_exists('ablecore_menu')) { $link = ablecore_menu_get_preferred_link(); } if ($link === false) { $active_trail = \menu_get_active_trail(); $link = $active_trail[count($active_trail) - 1]; } return $link; }
<?php /** * @file * Template for a block. */ // show the menu only for pages that are in the main menu $show_main_menu = FALSE; $menu_trail = menu_get_active_trail(); if (isset($menu_trail[1]['menu_name']) && $menu_trail[1]['menu_name'] == 'main-menu') { $show_main_menu = TRUE; } ?> <?php if ($show_main_menu) { ?> <div id="<?php print $block_html_id; ?> " class="<?php print $classes; ?> "<?php print $attributes; ?> > <div class="dropdown" role="navigation" aria-labelledby="section-button"> <button id="section-button" class="section-menu-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> MENU <span class="caret"></span>
?> <?php print $left; print $left_resource; ?> </div> </div> <?php } else { ?> <?php // If level is equal to 3, get and print the parent's name if ($level == 3) { print '<div id="home-tabs-left" class="internal"><div id="menu-left-internal">'; $menuParent = menu_get_active_trail(); //get rid of the last item in the array as it is the current page $menuParentPop = array_pop($menuParent); //Just grab the last item in the array now $menuParent = end($menuParent); //if it is not the home page and it is not an empty array if (!empty($menuParent) && $menuParent['link_path'] != '') { print '<ul><li class="third-level-parent">' . l($menuParent['title'], $menuParent['link_path']) . '</li></ul>'; } $menuItem = menu_link_get_preferred('node/' . $node->nid); print '<ul><li class="active">' . l($menuItem['link_title'], $menuItem['link_path']) . '</li></ul>'; print '</div></div>'; } ?> <?php }
/** function open_omega_system_themes_page_alter(&$theme_groups) { $hidden = array( 'alpha', 'omega', ); foreach ($theme_groups as $state => &$group) { if ($state == 'disabled') { foreach ($theme_groups[$state] as $id => &$theme) { if (in_array($theme, $hidden)) { unset($theme_groups[$state][$id]); } } } } } */ function agency_1_preprocess_region(&$vars) { global $language; switch ($vars['region']) { // menu region case 'menu': $footer_menu_cache = cache_get("footer_menu_data:" . $language->language); if ($footer_menu_cache) { $footer_menu = $footer_menu_cache->data; } else { $footer_menu = menu_tree_output(_agency_1_menu_build_tree('main-menu', array('max_depth' => 2))); cache_set("footer_menu_data:" . $language->language, $footer_menu); } //set the active trail $active_trail = menu_get_active_trail(); foreach ($active_trail as $trail) { if (isset($trail['mlid']) && isset($footer_menu[$trail['mlid']])) { $footer_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail'; } } $vars['dropdown_menu'] = $footer_menu; break; // default footer content // default footer content case 'footer_first': $footer_menu_cache = cache_get("footer_menu_data:" . $language->language); if ($footer_menu_cache) { $footer_menu = $footer_menu_cache->data; } else { $footer_menu = menu_tree_output(_agency_1_menu_build_tree('main-menu', array('max_depth' => 2))); cache_set("footer_menu_data", $footer_menu); } //set the active trail $active_trail = menu_get_active_trail(); foreach ($active_trail as $trail) { if (isset($trail['mlid']) && isset($footer_menu[$trail['mlid']])) { $footer_menu[$trail['mlid']]['#attributes']['class'][] = 'active-trail'; } } $vars['footer_menu'] = $footer_menu; $vars['site_name'] = $site_name = variable_get('site_name'); $vars['footer_logo'] = l(theme('image', array('path' => drupal_get_path('theme', 'agency_1') . "/logo-sm.png", 'alt' => "{$site_name} logo")), '', array("html" => TRUE, 'attributes' => array('class' => 'logo'))); //Branding $vars['display_footer_branding'] = theme_get_setting('display_footer_branding'); //Contact Us Block $vars['display_footer_contact'] = theme_get_setting('display_footer_contact'); $vars['footer_contact_us_title'] = theme_get_setting('footer_contact_us_title'); $vars['footer_contact_us_agency_title'] = theme_get_setting('footer_contact_us_agency_title'); $vars['footer_contact_us_address_1'] = theme_get_setting('footer_contact_us_address_1'); $vars['footer_contact_us_address_2'] = theme_get_setting('footer_contact_us_address_2'); $vars['footer_contact_us_phone'] = theme_get_setting('footer_contact_us_phone'); $vars['footer_contact_us_fax'] = theme_get_setting('footer_contact_us_fax'); $vars['footer_contact_us_map_link'] = theme_get_setting('footer_contact_us_map_link'); $vars['footer_contact_us_map_image'] = theme_get_setting('footer_contact_us_map_image'); $vars['footer_contact_us_title_link'] = theme_get_setting('footer_contact_us_title_link'); $vars['footer_contact_us_map_path'] = theme_get_setting('footer_contact_us_map_path'); if (function_exists('defaultcontent_get_node') && ($node = defaultcontent_get_node("email_update"))) { $node = node_view($node); $vars['subscribe_form'] = $node['webform']; } //krumo($vars['footer_menu']); break; } }
/** * Checks whether an item is active or in the active trail. * * This is based on the code in the core toolbar module * /modules/toolbar/toolbar.module function toolbar_in_active_trail($path) * * @param * The path of a menu item we're evaluating * * @return * An array of classes if active or in the active trail. * An empty array if not active or in the active trail. * * @todo * Look at migrating to a menu system level function. */ function _zurb_foundation_in_active_trail($link_path) { $classes = array(); $active_paths = array(); // Don't waste cycles: if we're on the front page, we're either active or not // and we don't need to look at the rest of the tree. if (drupal_is_front_page()) { if ($link_path == '<front>') { $classes[] = 'active'; } return $classes; } // If the current page matches the item path, it's active and we don't need to // look further. Comment out the return statement to have both 'active' and // 'active-trail' classes applied to the item for the current page. if ($link_path == current_path()) { $classes[] = 'active'; return $classes; } // If we're not on the front page and the current link is not the current page, // The we need to check the whole active trail. Since Drupal caches the result // of menu_get_active_trail(), this is not too costly. $active_trail = menu_get_active_trail(); $front = array_shift($active_trail); foreach ($active_trail as $item) { if (!empty($item['link_path'])) { $active_paths[$item['link_path']] = TRUE; } } if (!empty($active_paths[$link_path])) { $classes[] = 'active-trail'; } return $classes; }