You are here

function theme_accordion_menu_header in Accordion Menu 7

Same name and namespace in other branches
  1. 6 includes/view.inc \theme_accordion_menu_header()

Returns HTML for the accordion menu header and submenu items.

Parameters

array $variables: An associative array containing:

  • element: The menu object that is being formatted.

File

includes/view.inc, line 339
Provides view routines.

Code

function theme_accordion_menu_header(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';
  $header = check_plain($element['#config']['header']);
  $header_link = $element['#config']['header_link'];
  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  if (!$header_link && !empty($element['#below'])) {

    // @todo Allow the title to be output without cleansing based on user input.
    // Merge in defaults.
    $options = $element['#localized_options'];
    $options += array(
      'attributes' => array(),
      'html' => FALSE,
    );
    $tag = 'span';
    $link = '<' . $tag . drupal_attributes($options['attributes']) . '>' . ($options['html'] ? $element['#title'] : check_plain($element['#title'])) . '</' . $tag . '>';
  }
  else {
    $link = l($element['#title'], $element['#href'], $element['#localized_options']);
  }

  // The standard menu rendering nests the sub_menu items beneath the header.
  // For the accordion effect to work, the sub_menu must be wrapped in a "div"
  // following the header element.
  $output = '<' . $header . drupal_attributes($element['#attributes']) . '>' . $link . '</' . $header . '>' . "\n";
  return $output . '<div class="accordion-content-' . $element['#count'] . '">' . $sub_menu . '</div>' . "\n";
}