Last active
          August 29, 2015 14:06 
        
      - 
      
- 
        Save labboy0276/8a7c6b382ee89376415f to your computer and use it in GitHub Desktop. 
    Drupal Front Page Anchor Tags - Bootstrap
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function <YOURTHEME>_links__system_main_menu($variables) { | |
| $menu = ''; | |
| // Adds heading class | |
| $menu .= '<h2 class="'; | |
| foreach ($variables['heading']['class'] as $key) { | |
| $menu .= $key . ' '; | |
| } | |
| $menu .= '">Main menu</h2>'; | |
| // Adds UL classes | |
| $menu .= '<ul class="'; | |
| foreach ($variables['attributes']['class'] as $key) { | |
| $menu .= $key . ' '; | |
| } | |
| $menu .= '" role="menubar">'; | |
| // Adds LI classes | |
| foreach ($variables['links'] as $key => $value) { | |
| if (isset($value["#title"])) { | |
| $menu .= '<li class="mid-' . $key . ' '; | |
| if (isset($value['#attributes']['class'][0])) { | |
| $menu .= $value['#attributes']['class'][0]; | |
| } | |
| $menu .= '" role="presentation">'; | |
| switch ($value['#title']) { | |
| case 'About': | |
| $menu .= '<a href="#about"'; | |
| break; | |
| case 'Home': | |
| $menu .= '<a href="/"'; | |
| break; | |
| // WE CAN ADD OTHER CASES HERE LIKE ABOVE | |
| } | |
| if (isset($value['#original_link']['options']['attributes']['class'])) { | |
| $menu .= ' class="'; | |
| foreach ($value['#original_link']['options']['attributes']['class'] as $class) { | |
| $menu .= $class . ' '; | |
| } | |
| $menu .= '"'; | |
| } | |
| $menu .= ' role="menuitem">' . $value['#title'] . '</a></li>'; | |
| } | |
| } | |
| return $menu; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
u should use the l() function to output links:
https://api.drupal.org/api/drupal/includes%21common.inc/function/l/7