/** * Tests the menu functionality. */ function testMenus() { // Create a view with a page display and a menu link in the Main Menu. $view = array(); $view['label'] = $this->randomName(16); $view['id'] = strtolower($this->randomName(16)); $view['description'] = $this->randomName(16); $view['page[create]'] = 1; $view['page[title]'] = $this->randomName(16); $view['page[path]'] = $this->randomName(16); $view['page[link]'] = 1; $view['page[link_properties][menu_name]'] = 'main'; $view['page[link_properties][title]'] = $this->randomName(16); $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); // Make sure there is a link to the view from the front page (where we // expect the main menu to display). $this->drupalGet(''); $this->assertResponse(200); $this->assertLink($view['page[link_properties][title]']); $this->assertLinkByHref(url($view['page[path]'])); // Make sure the link is associated with the main menu. $links = menu_load_links('main'); $found = FALSE; foreach ($links as $link) { if ($link['link_path'] == $view['page[path]']) { $found = TRUE; break; } } $this->assertTrue($found, t('Found a link to %path in the main menu', array('%path' => $view['page[path]']))); }
public function handleEntity(array &$metadata = array()) { // Get the definition. $definition = $this->original_entity->definition; // Get the weights of the other menu item UUIDs associated with this link. $menu_links = menu_load_links($definition->menu_name); $sibling_links = array(); foreach ($menu_links as $link) { // If the menu links are at the same depth, or are at the same depth and // under the same parent if they're not at the root of the menu. if ($definition->depth == 1 && $link['depth'] == $definition->depth || $definition->depth > 1 && $link['depth'] == $definition->depth && $link['plid'] == $definition->plid) { $sibling_links[$link['uuid']] = $link['weight']; } } $metadata['sibling_link_weights'] = $sibling_links; }
/** * Override or insert variables into the page template. * * @param $variables * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("page" in this case.) */ function gwt_drupal_preprocess_page(&$variables, $hook) { global $base_url; // $variables['path_to_theme'] = $base_url.'/'.path_to_theme(); $js_variables = array('theme_path' => $base_url . '/' . path_to_theme()); drupal_add_js(array('gwt_drupal' => $js_variables), 'setting'); // drupal_add_js(drupal_get_path('theme', 'MYTHEME') .'/mytheme.js', 'file'); // Find the title of the menu used by the secondary links. $secondary_links = variable_get('menu_secondary_links_source', 'user-menu'); if ($secondary_links) { $menus = function_exists('menu_get_menus') ? menu_get_menus() : menu_list_system_menus(); $variables['secondary_menu_heading'] = $menus[$secondary_links]; } else { $variables['secondary_menu_heading'] = ''; } $variables['content_class'] = ''; $variables['sidebar_first_class'] = ' large-3 medium-3'; $variables['sidebar_second_class'] = ' large-3 medium-3'; if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) { $variables['content_class'] .= ' large-6 medium-6 large-push-3 medium-push-3'; $variables['sidebar_first_class'] .= ' large-pull-6 medium-push-6'; } elseif (!empty($variables['page']['sidebar_first']) && empty($variables['page']['sidebar_second'])) { $variables['content_class'] .= ' large-9 medium-9 large-push-3 medium-push-3'; $variables['sidebar_first_class'] .= ' large-pull-9 medium-pull-9'; } elseif (empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) { $variables['content_class'] .= ' large-9 medium-9'; } else { $variables['content_class'] .= ' large-12'; } // create a dynamic column on banner $variables['banner_class'] = ' large-12'; $variables['banner_2_class'] = ''; $variables['banner_3_class'] = ''; $variables['banner_container_class'] = ' has-border'; // TODO: bug! banner slider and container should not show (if no content on other content) if the banner is medium size media if (!empty($variables['page']['banner'])) { if (!empty($variables['page']['banner_2']) && !empty($variables['page']['banner_3'])) { $variables['banner_class'] = ' large-6'; $variables['banner_2_class'] = ' large-3'; $variables['banner_3_class'] = ' large-3'; } elseif (!empty($variables['page']['banner_2']) && empty($variables['page']['banner_3'])) { $variables['banner_class'] = ' large-8'; $variables['banner_2_class'] = ' large-4'; } elseif (empty($variables['page']['banner_2']) && !empty($variables['page']['banner_3'])) { $variables['banner_class'] = ' large-9'; $variables['banner_3_class'] = ' large-3'; } } elseif (empty($variables['page']['banner'])) { $variables['banner_class'] = ''; $variables['banner_container_class'] = ''; if (!empty($variables['page']['banner_2']) && !empty($variables['page']['banner_3'])) { $variables['banner_2_class'] = ' large-6'; $variables['banner_3_class'] = ' large-6'; } elseif (!empty($variables['page']['banner_2']) && empty($variables['page']['banner_3'])) { $variables['banner_2_class'] = ' large-12'; } elseif (empty($variables['page']['banner_2']) && !empty($variables['page']['banner_3'])) { $variables['banner_3_class'] = ' large-12'; } } // create a dynamic column on banner $variables['name_slogan_class'] = ' large-12'; $variables['ear_content_class'] = ''; $variables['ear_content_2_class'] = ''; // if both banner are available if (!empty($variables['page']['ear_content']) && !empty($variables['page']['ear_content_2'])) { $variables['name_slogan_class'] = ' large-6'; $variables['ear_content_class'] = ' large-3'; $variables['ear_content_2_class'] = ' large-3'; } elseif (!empty($variables['page']['ear_content']) && !empty($variables['page']['ear_content_2'])) { $variables['name_slogan_class'] = ' large-9'; $variables['ear_content_class'] = ' large-3'; //$variables['ear_content_2_class'] = ''; } elseif (empty($variables['page']['ear_content']) && !empty($variables['page']['ear_content_2'])) { $variables['name_slogan_class'] = ' large-9'; //$variables['ear_content_class'] = ''; $variables['ear_content_2_class'] = ' large-3'; } // TODO: make a function that parse multiple region columns // create a dynamic column on agency footer $variables['footer_class'] = ' large-12'; if (!empty($variables['page']['footer_2'])) { $variables['footer_class'] = ' large-6'; $variables['footer_2_class'] = ' large-6'; $variables['footer_3_class'] = ' large-3'; $variables['footer_4_class'] = ' large-3'; if (!empty($variables['page']['footer_3']) && !empty($variables['page']['footer_4'])) { $variables['footer_class'] = ' large-3'; $variables['footer_2_class'] = ' large-3'; } elseif (empty($variables['page']['footer_3']) && !empty($variables['page']['footer_4'])) { $variables['footer_2_class'] = ' large-3'; } elseif (!empty($variables['page']['footer_3']) && empty($variables['page']['footer_4'])) { $variables['footer_class'] = ' large-4'; $variables['footer_2_class'] = ' large-4'; $variables['footer_3_class'] = ' large-4'; } } else { $variables['footer_class'] = ' large-6'; $variables['footer_3_class'] = ' large-3'; $variables['footer_4_class'] = ' large-3'; if (empty($variables['page']['footer_3']) && !empty($variables['page']['footer_4'])) { $variables['footer_4_class'] = ' large-6'; } elseif (!empty($variables['page']['footer_3']) && empty($variables['page']['footer_4'])) { $variables['footer_3_class'] = ' large-6'; } } // create a dynamic column on agency panel_top $variables['panel_top_class'] = ' large-12'; if (!empty($variables['page']['panel_top_2'])) { $variables['panel_top_class'] = ' large-6'; $variables['panel_top_2_class'] = ' large-6'; $variables['panel_top_3_class'] = ' large-3'; $variables['panel_top_4_class'] = ' large-3'; if (!empty($variables['page']['panel_top_3']) && !empty($variables['page']['panel_top_4'])) { $variables['panel_top_class'] = ' large-3'; $variables['panel_top_2_class'] = ' large-3'; } elseif (empty($variables['page']['panel_top_3']) && !empty($variables['page']['panel_top_4'])) { $variables['panel_top_2_class'] = ' large-3'; } elseif (!empty($variables['page']['panel_top_3']) && empty($variables['page']['panel_top_4'])) { $variables['panel_top_class'] = ' large-4'; $variables['panel_top_2_class'] = ' large-4'; $variables['panel_top_3_class'] = ' large-4'; } } else { $variables['panel_top_class'] = ' large-12'; $variables['panel_top_3_class'] = ' large-3'; $variables['panel_top_4_class'] = ' large-3'; if (empty($variables['page']['panel_top_3']) && !empty($variables['page']['panel_top_4'])) { $variables['panel_top_4_class'] = ' large-6'; } elseif (!empty($variables['page']['panel_top_3']) && empty($variables['page']['panel_top_4'])) { $variables['panel_top_3_class'] = ' large-6'; } } // create a dynamic column on agency panel_bottom $variables['panel_bottom_class'] = ' large-12'; if (!empty($variables['page']['panel_bottom_2'])) { $variables['panel_bottom_class'] = ' large-6'; $variables['panel_bottom_2_class'] = ' large-6'; $variables['panel_bottom_3_class'] = ' large-3'; $variables['panel_bottom_4_class'] = ' large-3'; if (!empty($variables['page']['panel_bottom_3']) && !empty($variables['page']['panel_bottom_4'])) { $variables['panel_bottom_class'] = ' large-3'; $variables['panel_bottom_2_class'] = ' large-3'; } elseif (empty($variables['page']['panel_bottom_3']) && !empty($variables['page']['panel_bottom_4'])) { $variables['panel_bottom_2_class'] = ' large-3'; } elseif (!empty($variables['page']['panel_bottom_3']) && empty($variables['page']['panel_bottom_4'])) { $variables['panel_bottom_class'] = ' large-4'; $variables['panel_bottom_2_class'] = ' large-4'; $variables['panel_bottom_3_class'] = ' large-4'; } } else { $variables['panel_bottom_class'] = ' large-6'; $variables['panel_bottom_3_class'] = ' large-3'; $variables['panel_bottom_4_class'] = ' large-3'; if (empty($variables['page']['panel_bottom_3']) && !empty($variables['page']['panel_bottom_4'])) { $variables['panel_bottom_4_class'] = ' large-6'; } elseif (!empty($variables['page']['panel_bottom_3']) && empty($variables['page']['panel_bottom_4'])) { $variables['panel_bottom_3_class'] = ' large-6'; } } // load the color used from theme_settings // TODO: use the drupal way of printing attributes $variables['gwt_drupal_masthead_styles'] = 'style=" '; if ($gwt_drupal_masthead_bg_color = theme_get_setting('gwt_drupal_masthead_bg_color')) { $variables['gwt_drupal_masthead_styles'] .= 'background-color: ' . $gwt_drupal_masthead_bg_color . '; '; } $masthead_fid = theme_get_setting('gwt_drupal_masthead_bg_image'); if ($masthead_fid) { $file = file_load($masthead_fid); if (isset($file->uri)) { $variables['gwt_drupal_masthead_styles'] .= 'background-image: url(' . file_create_url($file->uri) . '); '; } } if ($gwt_drupal_masthead_font = theme_get_setting('gwt_drupal_masthead_font_color')) { $variables['gwt_drupal_masthead_styles'] .= 'color: ' . $gwt_drupal_masthead_font . '; '; } $variables['gwt_drupal_masthead_styles'] .= '" '; $variables['gwt_drupal_banner_styles'] = 'style=" '; if ($gwt_drupal_banner_bg_color = theme_get_setting('gwt_drupal_banner_bg_color')) { $variables['gwt_drupal_banner_styles'] .= 'background-color: ' . $gwt_drupal_banner_bg_color . '; '; } $banner_fid = theme_get_setting('gwt_drupal_banner_bg_image'); if ($banner_fid) { $file = file_load($banner_fid); if (isset($file->uri)) { $variables['gwt_drupal_banner_styles'] .= 'background-image: url(' . file_create_url($file->uri) . '); '; } } if ($gwt_drupal_banner_font = theme_get_setting('gwt_drupal_banner_font_color')) { $variables['gwt_drupal_banner_styles'] .= 'color: ' . $gwt_drupal_banner_font . '; '; } $variables['gwt_drupal_banner_styles'] .= '" '; // TODO: check if the auxiliary_menu is available $variables['menu_auxiliary_menu'] = ''; if (menu_load_links('menu-auxiliary-menu')) { $variables['menu_auxiliary_menu'] = menu_load_links('menu-auxiliary-menu'); } $accessibility = array(); /* $gwt_drupal_acc_statement = theme_get_setting('gwt_drupal_acc_statement') ? theme_get_setting('gwt_drupal_acc_statement') : ''; if($gwt_drupal_acc_statement){ $accessibility[] = array( 'url' => $gwt_drupal_acc_statement, 'text' => t('Accessibility Statement'), 'key' => '0', 'class' => array('toggle-statement'), ); } */ $gwt_drupal_acc_home = theme_get_setting('gwt_drupal_acc_home') ? theme_get_setting('gwt_drupal_acc_home') : ''; if ($gwt_drupal_acc_home) { $accessibility[] = array('url' => $gwt_drupal_acc_home, 'text' => t('Home'), 'key' => '1'); } $gwt_drupal_acc_faq = theme_get_setting('gwt_drupal_acc_faq') ? theme_get_setting('gwt_drupal_acc_faq') : ''; if ($gwt_drupal_acc_faq) { $accessibility[] = array('url' => $gwt_drupal_acc_faq, 'text' => t('Faqs'), 'key' => '5'); } $gwt_drupal_acc_contact = theme_get_setting('gwt_drupal_acc_contact') ? theme_get_setting('gwt_drupal_acc_contact') : ''; if ($gwt_drupal_acc_contact) { $accessibility[] = array('url' => $gwt_drupal_acc_contact, 'text' => t('Contact'), 'key' => 'c'); } $gwt_drupal_acc_feedback = theme_get_setting('gwt_drupal_acc_feedback') ? theme_get_setting('gwt_drupal_acc_feedback') : ''; if ($gwt_drupal_acc_feedback) { $accessibility[] = array('url' => $gwt_drupal_acc_feedback, 'text' => t('Feedbacks'), 'key' => 'k'); } $gwt_drupal_acc_search = theme_get_setting('gwt_drupal_acc_search') ? theme_get_setting('gwt_drupal_acc_search') : 'search/node/'; if ($gwt_drupal_acc_search) { $accessibility[] = array('url' => $gwt_drupal_acc_search, 'text' => t('Search'), 'key' => 's'); } // accesibility page that loads all the accesibility theme_settings. $variables['accesibility'] = '<ul>'; $gwt_drupal_acc_maincontent = theme_get_setting('gwt_drupal_acc_maincontent') ? theme_get_setting('gwt_drupal_acc_maincontent') : '#main-content'; if ($gwt_drupal_acc_maincontent) { $variables['accesibility'] .= '<li><a href="' . $gwt_drupal_acc_maincontent . '" accesskey="R">Skip to Main Content</a></li>'; } $gwt_drupal_acc_sitemap = theme_get_setting('gwt_drupal_acc_sitemap') ? theme_get_setting('gwt_drupal_acc_sitemap') : '#footer'; if ($gwt_drupal_acc_sitemap) { $variables['accesibility'] .= '<li><a href="' . $gwt_drupal_acc_sitemap . '" accesskey="M">Sitemap</a></li>'; } $variables['accesibility'] .= '</ul>'; /*$test = l( $accessibility[0]['text'], $accessibility[0]['url'], array( 'attributes' => array( 'accesskey' => 0, 'class' => 'skips', ), )); // drupal_set_message('<pre>'.print_r($data['class'], 1).'</pre>'); drupal_set_message('<pre>'.print_r($test, 1).'</pre>');*/ $variables['accesibility_shortcut'] = '<ul>'; $variables['accesibility_shortcut'] .= '<li><a href="#" class="skips toggle-statement" title="Toggle Accessibility Statement" accesskey="0">Toggle Accessibility Statement</a></li>'; foreach ($accessibility as $access_key => $data) { $data['class'] = isset($data['class']) && is_array($data['class']) ? $data['class'] : array(); $variables['accesibility_shortcut'] .= '<li>'; $variables['accesibility_shortcut'] .= l($data['text'], $data['url'], array('attributes' => array('class' => array_merge(array('skips'), $data['class']), 'accesskey' => $data['key']))); $variables['accesibility_shortcut'] .= '</li>'; } $variables['accesibility_shortcut'] .= '</ul>'; $variables['accessibility_widget'] = theme_get_setting('gwt_drupal_acc_widget'); if (module_exists('gwt_drupal_helper')) { $variables['gwt_mega_menu'] = _gwt_drupal_mega_menu_formatted(); } }
<?php global $base_path; $main_menu = menu_load_links('main-menu'); ?> <div class="navbar" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="<?php print $base_path; ?> ">College Women <img src="<?php print $base_path; ?> themes/sisters/resources/images/beta-badge.svg" alt="Beta" /> <small class="hidden-sm">Documenting the History of Women in Higher Education</small></a> </div> <div class="collapse navbar-collapse"> <ul class="nav navbar-nav nav-links"> <?php foreach ($main_menu as $menu) { ?> <?php
<?php global $base_path; $footer_menu = menu_load_links('menu-footer-menu-links'); ?> <div class="schools"> <div class="container"> <div class="homepage-college-info"> <div class="row"> <div class="col-md-12"> <ul class="list-inline college-list text-center"> <li><a href="https://barnard.edu/" target="_blank"><img alt="Barnard College logo" class="img-responsive" src="<?php echo $base_path; ?> themes/sisters/resources/assets/logo_barnard.jpg" style="height:88px; width:230px" /></a></li> <li><a href="https://www.brynmawr.edu/" target="_blank"><img alt="Bryn Mawr College logo" class="img-responsive" src="<?php echo $base_path; ?> themes/sisters/resources/assets/logo_brynmawr.jpg" style="height:88px; width:230px" /></a></li> <li><a href="https://www.mtholyoke.edu/" target="_blank"><img alt="Mount Holyoke College logo" class="img-responsive" src="<?php echo $base_path; ?> themes/sisters/resources/assets/logo_mtholyoke.jpg" style="height:88px; width:230px" /></a></li> <li><a href="http://www.radcliffe.harvard.edu/" target="_blank"><img alt="Radcliffe Institute logo" class="img-responsive" src="<?php echo $base_path; ?> themes/sisters/resources/assets/logo_radcliffe.jpg" style="height:88px; width:230px" /></a></li> <li><a href="http://www.smith.edu/" target="_blank"><img alt="Smith College logo" class="img-responsive" src="<?php echo $base_path; ?>
public function getLinks() { return menu_load_links($this->menu_name); }