drupalprojects / kalatheme

Mirror of http://drupal.org/project/kalatheme provided by hubdrop.
http://hubdrop.org/project/kalatheme
GNU General Public License v2.0
22 stars 29 forks source link

Convert kalatheme_links__system_main_menu #276

Open labboy0276 opened 8 years ago

labboy0276 commented 8 years ago

Reference: https://www.drupal.org/node/1354#themepreprocess

Convert kalatheme_links__system_main_menu in includes/menu.inc to template_preprocess_menu__main(&$variables) in KalathemeBootstrap Class (John added placeholder it to the interface):

Add in menu--main.html.twig

The theming in the menu system is a little different and this seems to be right based on John's research. If not, just correct it to the way that wins.

Also there is some residual code for this in kalatheme_preprocess_page (move to preprocess):

  // Get the menu tree for the menu that is set as 'Source for the Main links'.
  $main_links_menu = variable_get('menu_main_links_source', 'main-menu');
  $main_menu_tree = menu_tree_all_data($main_links_menu, NULL, 2);

  // Add the rendered output to the $main_menu_expanded variable.
  $main_menu_expanded = menu_tree_output($main_menu_tree);

  // Prepare the primary_nav
  $pri_attributes = array(
    'class' => array(
      'nav',
      'navbar-nav',
      'links',
      'clearfix',
    ),
  );
  if (!$variables['main_menu']) {
    $pri_attributes['class'][] = 'sr-only';
  }
  $variables['primary_nav'] = array(
    '#theme' => 'links__system_main_menu',
    '#links' => $main_menu_expanded,
    '#attributes' => $pri_attributes,
    '#heading' => array(
      'text' => t('Main menu'),
      'level' => 'h2',
      'class' => array('sr-only'),
    ),
  );