/** * Add current page to breadcrumb */ function urbanmediaspace_mothership_breadcrumb($breadcrumb) { if (!empty($breadcrumb)) { // Find the source node for translation nodes. $source = translation_path_get_translations($_GET['q']); if ($source) { $source = $source['da']; } else { $source = $_GET['q']; } $menu = db_fetch_object(db_query("SELECT menu_name\n FROM {menu_links}\n WHERE link_path = '%s'", $source))->menu_name; // Change the active item to source node, to make active trail work and back // again to not crash other parts of the page, after getting the menu tree. $old_path = $_GET['q']; menu_set_active_item($source); $tree = menu_tree_page_data($menu); menu_set_active_item($old_path); // Find active trail. global $language; $trail = array(); urbanmediaspace_mothership_active_trail($tree, $trail, $language->language); // Found trail, lets create links. if (!empty($trail)) { // Reset breadcrumb (do to menu_set_active_trail). $breadcrumb = array(l(t('Home'), '<front>')); // Build new breadcrumb. $size = count($trail) - 1; for ($i = 0; $i < $size; $i++) { $breadcrumb[] = l($trail[$i]['title'], $trail[$i]['link_path']); } // Insert project, if the 3dmodel is shown. if (arg(0) == '3dmodel') { $breadcrumb[] = l(t('Project'), 'projektet'); } // Last item should not be at link. $breadcrumb[] = t($trail[$i]['title']); } else { if (arg(1) == 'apachesolr_search') { // Fix link to search. $breadcrumb[1] = l(t('Search'), 'search/apachesolr_search'); } else { // User current page title, as no trail was found. $title = drupal_get_title(); if (!empty($title)) { $breadcrumb[] = t($title); } } } return '<div class="breadcrumb">' . implode(' > ', $breadcrumb) . '</div>'; } }
/** 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']); }
function epf_preprocess_page(&$variables) { $menus = menu_tree_page_data('main-menu'); //$router_item = menu_get_item(); $links = array(); foreach ($menus as $item) { if (!$item['link']['hidden']) { $l = $item['link']['localized_options']; $l['href'] = $item['link']['href']; $l['title'] = $item['link']['title']; if ($item['link']['has_children'] > 0 && $item['below']) { foreach ($item['below'] as $itemb) { $lb = $itemb['link']['localized_options']; $lb['href'] = $itemb['link']['href']; $lb['title'] = $itemb['link']['title']; $l['below']['menu-' . $itemb['link']['mlid']] = $lb; } } // Keyed with the unique mlid to generate classes in theme_links(). $links['menu-' . $item['link']['mlid']] = $l; } } $variables['main_menu'] = $links; }
/** * Preprocess variables for page.tpl.php * * @see page.tpl.php */ function twitter_bootstrap_preprocess_page(&$variables) { // Add information about the number of sidebars. if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) { $variables['columns'] = 3; } elseif (!empty($variables['page']['sidebar_first'])) { $variables['columns'] = 2; } elseif (!empty($variables['page']['sidebar_second'])) { $variables['columns'] = 2; } else { $variables['columns'] = 1; } // Our custom search because its cool :) $variables['search'] = FALSE; if (theme_get_setting('toggle_search') && module_exists('search')) { $variables['search'] = drupal_get_form('_twitter_bootstrap_search_form'); } // Primary nav $variables['primary_nav'] = FALSE; if ($variables['main_menu']) { // Build links $tree = menu_tree_page_data(variable_get('menu_main_links_source', 'main-menu')); $variables['main_menu'] = twitter_bootstrap_menu_navigation_links($tree); // Build list $variables['primary_nav'] = theme('twitter_bootstrap_links', array('links' => $variables['main_menu'], 'attributes' => array('id' => 'main-menu', 'class' => array('nav')), 'heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible')))); } // 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'] = twitter_bootstrap_menu_navigation_links($tree); // Build list $variables['secondary_nav'] = theme('twitter_bootstrap_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 dropw down version $variables['tabs']['#primary'] = _twitter_bootstrap_local_tasks($variables['tabs']['#primary']); }
</div> <?php } ?> <div id="home-tabs" class='<?php print $header_wrapper_height; ?> '> <?php // Fetch the menu tree for the current page. $tree = menu_tree_page_data('main-menu'); $level = 0; // Go down the active trail as far as possible. while ($tree) { // Loop through the current level's items until we find one that is in trail. while ($item = array_shift($tree)) { if ($item['link']['in_active_trail']) { // If the item is in the active trail, we count a new level. $level++; if (!empty($item['below'])) { // If more items are available, we continue down the tree. $tree = $item['below']; break; } // If we are at the end of the tree, our work here is done. break 2;
<?php $thisTitle = ""; $menus = menu_tree_page_data('primary-links'); foreach ($menus as $menu) { if (!empty($menu['link']['in_active_trail']) && $menu['link']['has_children']) { $thisTitle = $menu['link']['title']; } } // set left column width if (theme_get_setting(splitmenu_col) == "leftcol" and $iridium_menu_type == "splitmenu" and $thisTitle != "" and !$is_front or $left) { $current_leftcolumn_width = theme_get_setting('leftcolumn_width'); } else { $current_leftcolumn_width = 0; } // set right column width if (theme_get_setting(splitmenu_col) == "rightcol" and $iridium_menu_type == "splitmenu" and $thisTitle != "" and !$is_front or $right) { $current_rightcolumn_width = theme_get_setting('rightcolumn_width'); } else { $current_rightcolumn_width = 0; } // set insetwidth if ($inset and arg(0) != "admin") { $current_left_inset_width = theme_get_setting('leftinset_width'); //$current_left_inset_width = 0; } else { $current_left_inset_width = 0; } if ($inset2 and arg(0) != "admin") { $current_right_inset_width = theme_get_setting('rightinset_width'); //$current_right_inset_width = 0;
<?php $main_links = menu_tree_page_data(variable_get('menu_main_links_source', 'main-menu')); $main_links = menu_tree_output($main_links); $secondary_links = menu_tree_page_data(variable_get('menu_secondary_links_source', 'user-menu')); $secondary_links = menu_tree_output($secondary_links); ?> <div<?php print $attributes; ?> > <div<?php print $content_attributes; ?> > <?php if ($main_links) { ?> <nav class="navigation"> <?php print render($main_links); ?> </nav> <?php } ?> <?php if ($secondary_links) { ?> <nav class="navigation-secondary"> <?php
/** * Implements template_preprocess_page(). */ function humanitarianresponse_preprocess_page(&$variables) { global $theme_path; $tree = menu_tree_page_data('main-menu', 1); $main_menu_dropdown = menu_tree_output($tree); $main_menu_dropdown['#theme_wrappers'] = array(); $variables['main_menu_dropdown'] = $main_menu_dropdown; $variables['hr_tabs'] = array(); $header_img_path = $theme_path.'/assets/images/headers/general.png'; if (module_exists('og_context')) { $gid = og_context_determine_context('node'); if (!empty($gid)) { $og_group = entity_load('node', array($gid)); $og_group = $og_group[$gid]; if ($og_group->type == 'hr_operation') { // Salahumanitaria logo if ($og_group->nid == 77) { // Nid of the Colombia operation $variables['logo'] = '/sites/all/themes/humanitarianresponse/assets/images/salahumanitaria_logo.png'; } if (!empty($og_group->field_operation_type) && !empty($og_group->field_operation_region) && $og_group->field_operation_type[LANGUAGE_NONE][0]['value'] == 'country') { // Determine the region of the operation $region_id = $og_group->field_operation_region[LANGUAGE_NONE][0]['target_id']; $region = entity_load_single('node', $region_id); $region_uri = entity_uri('node', $region); $region_status = $region->field_operation_status[LANGUAGE_NONE][0]['value']; switch ($region_status) { case 'active': // Add the region to the tabs $variables['hr_tabs'][] = l($region->title, $region_uri['path'], $region_uri['options']); break; case 'inactive': break; case 'archived': break; } } } elseif ($og_group->type == 'hr_disaster') { $glide = $og_group->field_glide_number[LANGUAGE_NONE][0]['value']; if ($glide == 'EP-2014-000041-GIN') { $variables['logo'] = '/sites/all/themes/humanitarianresponse/assets/images/unmeer_logo.png'; } } elseif ($og_group->type == 'hr_bundle') { // Get operation from bundle $op_gid = _hr_bundles_get_operation($og_group->nid); if (!empty($op_gid)) { $operation = entity_load_single('node', $op_gid); $op_uri = entity_uri('node', $operation); $variables['hr_tabs'][] = l($operation->title, $op_uri['path'], $op_uri['options']); } } $uri = entity_uri('node', $og_group); if ($og_group->status) { // Group is published $variables['hr_tabs'][] = l($og_group->title, $uri['path'], $uri['options']); } else { $variables['hr_tabs'][] = '<a href="#">'.$og_group->title.'</a>'; } $group_img_path = '/assets/images/headers/'.$og_group->type.'/'.strtolower(str_replace(array(' ','/'), '-', $og_group->title)).'.png'; if (file_exists(dirname(__FILE__).$group_img_path)) { $header_img_path = $theme_path.$group_img_path; } } } $variables['og_group_header_image'] = theme('image', array( 'path' => $header_img_path, 'alt' => 'Header image', )); if (user_is_anonymous()) { $variables['follow_us_link_href'] = 'user/login'; $variables['follow_us_link_title'] = t('Login to follow us'); $variables['follow_us_link_status'] = 'flag'; } else { $temp = _humanitarianresponse_flag_follow_us(); $variables['follow_us_link_href'] = $temp['link_href']; $variables['follow_us_link_title'] = $temp['link_title']; $variables['follow_us_link_status'] = $temp['link_status']; } $variables['hr_favorite_spaces'] = _humanitarianresponse_block_render('hr_bookmarks', 'hr_favorite_spaces'); }
/** * override menu tree **/ function custom_menu_tree($menu_name) { $menu_output =& drupal_static(__FUNCTION__, array()); if (!isset($menu_output[$menu_name])) { $tree = menu_tree_page_data($menu_name); $menu_output[$menu_name] = custom_menu_tree_output($tree); } return $menu_output[$menu_name]; }
/** PAGE.TPL.PHP PREPROCESS VARIABLES ---------------------------------------------------------- */ function megatron_preprocess_page(&$variables) { // Define CLF page elements in an include require_once 'includes/template-ubc-clf-elements.inc'; // Add template suggestions based on content type if (isset($variables['node'])) { //$variables['theme_hook_suggestions'][] = 'page' . theme_get_setting('clf_layout') . ''; $variables['theme_hook_suggestions'][] = 'page__type__' . $variables['node']->type; } // Add information about the number of sidebars. if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second']) && !drupal_is_front_page()) { $variables['columns'] = 3; } elseif (!empty($variables['page']['sidebar_first']) && !drupal_is_front_page()) { $variables['columns'] = 2; } elseif (!empty($variables['page']['sidebar_second']) && !drupal_is_front_page()) { $variables['columns'] = 2; } elseif (!empty($variables['page']['sidebar_first']) && drupal_is_front_page()) { $variables['columns'] = 4; } else { $variables['columns'] = 1; } // Primary nav $variables['primary_nav'] = FALSE; if ($variables['main_menu']) { // Build links $tree = menu_tree_page_data(variable_get('menu_main_links_source', 'main-menu')); $variables['main_menu'] = megatron_menu_navigation_links($tree); // Build list $variables['primary_nav'] = theme('megatron_links', array('heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible')), 'links' => $variables['main_menu'], 'attributes' => array('id' => 'main-menu', 'class' => array('nav')))); } }
/** * Theme function to allow any menu tree to be themed as a Superfish menu. */ function magnetto_superfish($variables) { global $user, $language; $id = $variables['id']; $menu_name = $variables['menu_name']; $mlid = $variables['mlid']; $sfsettings = $variables['sfsettings']; $menu = menu_tree_all_data($menu_name); if (function_exists('i18n_menu_localize_tree')) { $menu = i18n_menu_localize_tree($menu); } // For custom $menus and menus built all the way from the top-level we // don't need to "create" the specific sub-menu and we need to get the title // from the $menu_name since there is no "parent item" array. // Create the specific menu if we have a mlid. if (!empty($mlid)) { // Load the parent menu item. $item = menu_link_load($mlid); $title = check_plain($item['title']); $parent_depth = $item['depth']; // Narrow down the full menu to the specific sub-tree we need. for ($p = 1; $p < 10; $p++) { if ($sub_mlid = $item["p{$p}"]) { $subitem = menu_link_load($sub_mlid); $key = 50000 + $subitem['weight'] . ' ' . $subitem['title'] . ' ' . $subitem['mlid']; $menu = isset($menu[$key]['below']) ? $menu[$key]['below'] : $menu; } } } else { $result = db_query("SELECT title FROM {menu_custom} WHERE menu_name = :a", array(':a' => $menu_name))->fetchField(); $title = check_plain($result); } $output['content'] = ''; $output['subject'] = $title; if ($menu) { // Set the total menu depth counting from this parent if we need it. $depth = $sfsettings['depth']; $depth = $sfsettings['depth'] > 0 && isset($parent_depth) ? $parent_depth + $depth : $depth; $var = array('id' => $id, 'menu' => $menu, 'depth' => $depth, 'trail' => superfish_build_page_trail(menu_tree_page_data($menu_name)), 'sfsettings' => $sfsettings); if ($menu_tree = theme('superfish_build', $var)) { if ($menu_tree['content']) { // Add custom HTML codes around the main menu. if ($sfsettings['wrapmul'] && strpos($sfsettings['wrapmul'], ',') !== FALSE) { $wmul = explode(',', $sfsettings['wrapmul']); // In case you just wanted to add something after the element. if (drupal_substr($sfsettings['wrapmul'], 0) == ',') { array_unshift($wmul, ''); } } else { $wmul = array(); } $output['content'] = isset($wmul[0]) ? $wmul[0] : ''; $output['content'] .= '<ul id="main-menu"'; //'<ul id="superfish-' . $id . '"'; $output['content'] .= ' class="menu sf-menu sf-' . $menu_name . ' sf-' . $sfsettings['type'] . ' sf-style-' . $sfsettings['style']; $output['content'] .= $sfsettings['itemcounter'] ? ' sf-total-items-' . $menu_tree['total_children'] : ''; $output['content'] .= $sfsettings['itemcounter'] ? ' sf-parent-items-' . $menu_tree['parent_children'] : ''; $output['content'] .= $sfsettings['itemcounter'] ? ' sf-single-items-' . $menu_tree['single_children'] : ''; $output['content'] .= $sfsettings['ulclass'] ? ' ' . $sfsettings['ulclass'] : ''; $output['content'] .= $language->direction == 1 ? ' rtl' : ''; $output['content'] .= '">' . $menu_tree['content'] . '</ul>'; $output['content'] .= isset($wmul[1]) ? $wmul[1] : ''; } } } return $output; }
function _mobilizer_menu_drop() { global $base_url; $main_menu_tree = $parrent_menu_items = menu_tree_page_data('menu-website-mobilizer', $max_depth = 1, $only_active_trail = FALSE); //menu_tree(variable_get('menu_main_links_source', 'menu-website-mobilizer')); $menu_list = '<ul class="menu">'; $menu_count = count($main_menu_tree); foreach ($main_menu_tree as $key => $value) { if (!$value['link']['hidden']) { $menu_image = mobilizer_get_menu_icons_menu_id($value['link']['mlid'], $value['link']['link_title']); $menu_list .= '<li>' . l(t('<div class="ico">' . $menu_image . ' </div><span>' . $value['link']['link_title'] . '</span> <span class="arrow"><img src="' . $base_url . '/' . path_to_theme('mobilizer') . '/images/arrow.png" />'), $value['link']['link_path'], array('html' => TRUE, 'attributes' => array('title' => $value['link']['link_title']))) . '</span><div class="clear"></div></li>'; } } $menu_list .= '</ul>'; return $menu_list; }