Share icon

Steps to create sub theme and mutilevel dropdown :-

1. Download the Bootstrap theme from the drupal sites here.

2. Create the subtheme using cdn folder (/bootsrap/starterkits/cdn) , Copy the cdn folder and place the same level folder as main bootstarp folder (sites/all/themes/cdn).

3. Now rename the cdn to you theme name like BootSmarter in case of drupal.key2goal.com and rename the cdn.starterkit to BootSmarter.info and edit that file to give your theme name or add script etc.

4.enable the theme for appearance admin menu drupal admin side.

5.Now For Mutilevel sub menu create a mutilevel links in main menu .

6. Now go to sites/all/Bootsmarter/template.php and edit, Placed this code 

 Note: Single level dropdown works without this code.


function BootSmarter_menu_tree(&$variables) {

  return '<div class="nav-collapse"><ul class="dropdown-menu multi-level">' . $variables['tree'] . '</ul></div>'; // added the nav-collapse wrapper so you can hide the nav at small size

}

function BootSmarter_menu_link(array $variables) {

  $element = $variables['element'];

  $sub_menu = '';

 

  if ($element['#below']) {

    // Prevent dropdown functions from being added to management menu so it

    // does not affect the navbar module.

    if (($element['#original_link']['menu_name'] == 'management') && (module_exists('navbar'))) {

      $sub_menu = drupal_render($element['#below']);

    }

    //Here we need to change from ==1 to >=1 to allow for multilevel submenus

    elseif ((!empty($element['#original_link']['depth'])) && ($element['#original_link']['depth'] >= 1)) {

      // Add our own wrapper.

      unset($element['#below']['#theme_wrappers']);

      $sub_menu = '<ul class="dropdown-menu sub-menu-'.$element['#original_link']['depth'].'">' . drupal_render($element['#below']) . '</ul>';

      // Generate as standard dropdown.

      $element['#title'] .= ' <span class="caret"></span>';

      $element['#attributes']['class'][] = 'dropdown';

      $element['#localized_options']['html'] = TRUE;

 

      // Set dropdown trigger element to # to prevent inadvertant page loading

      // when a submenu link is clicked.

      $element['#localized_options']['attributes']['data-target'] = '#';

      $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';

      //comment element bellow if you want your parent menu links to be "clickable"

      //$element['#localized_options']['attributes']['data-toggle'] = 'dropdown';

    }

  }

  // On primary navigation menu, class 'active' is not set on active menu item.

  // @see https://drupal.org/node/1896674

  if (($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#localized_options']['language']))) {

    $element['#attributes']['class'][] = 'active';

  }

  $output = l($element['#title'], $element['#href'], $element['#localized_options']);

  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";

}

function bootgsv_preprocess_page(array &$variables) {

  // Add information about the number of sidebars.

  if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {

    $variables['content_column_class'] = ' class="col-sm-6"';

  }

  elseif (!empty($variables['page']['sidebar_first']) || !empty($variables['page']['sidebar_second'])) {

    $variables['content_column_class'] = ' class="col-sm-8"';

  }

  else {

    $variables['content_column_class'] = ' class="col-sm-12"';

  }

}


7. put the css in style.css also:

 

ul.nav li.dropdown:hover > ul.dropdown-menu {display: block;}

8.Done.

Add new comment

Restricted HTML