3

I'm adapting my bootstrap html theme to Drupal 7 and want to use some of the features of Bootstrap 3 theme.

In Bootstrap theme, there is a code for accordion menu like this:

/**
 * Implements theme_bootstrap_bare().
 */
function bootstrap_bootstrap_accordion($variables) {
  $elements = $variables['elements'];

  if (empty($variables['id'])) {
    $accordion_id = 'accordion-' . md5($elements);
  }
  else {
    $accordion_id = check_plain($variables['id']);
  }
  $output = '<div class="accordion" id="' . $accordion_id . '">';
  foreach ($elements as $id => $item) {
    $output .= '<div class="accordion-group"><div class="accordion-heading">';
    $output .= '<a class="accordion-toggle" data-toggle="collapse" data-parent="#' . $accordion_id . '" href="#' . $id . '">' . check_plain($item['header']) . '</a></div>';
    $output .= '<div id="' . $id . '" class="accordion-body collapse in"><div class="accordion-inner">';
    $output .= render($item['content']);
    $output .= '</div></div></div>';
  }
  $output .= '</div>';
  return $output;
}

My problem is, how can i use this code in my theme for all menus in sidebar region?

4

Download Views Bootstrap and create a view for the menu you want to display as accordion. For your view format choose Bootstrap Accordion

Bootstrap Views

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.