You are here

function theme_ctools_dropdown in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/dropdown.theme.inc \theme_ctools_dropdown()

Create a dropdown menu.

Parameters

$title: The text to place in the clickable area to activate the dropdown.

$links: A list of links to provide within the dropdown, suitable for use in via Drupal's theme('links').

$image: If true, the dropdown link is an image and will not get extra decorations that a text dropdown link will.

$class: An optional class to add to the dropdown's container div to allow you to style a single dropdown however you like without interfering with other dropdowns.

File

includes/dropdown.theme.inc, line 57
Provide a javascript based dropdown menu.

Code

function theme_ctools_dropdown($title, $links, $image = FALSE, $class = '') {

  // Provide a unique identifier for every dropdown on the page.
  static $id = 0;
  $id++;
  $class = 'ctools-dropdown-no-js ctools-dropdown' . ($class ? ' ' . $class : '');
  ctools_add_js('dropdown');
  ctools_add_css('dropdown');
  $output = '';
  $output .= '<div class="' . $class . '" id="ctools-dropdown-' . $id . '">';
  $output .= '<div class="ctools-dropdown-link-wrapper">';
  if ($image) {
    $output .= '<a href="#" class="ctools-dropdown-link ctools-dropdown-image-link">' . $title . '</a>';
  }
  else {
    $output .= '<a href="#" class="ctools-dropdown-link ctools-dropdown-text-link">' . check_plain($title) . '</a>';
  }
  $output .= '</div>';

  // wrapper
  $output .= '<div class="ctools-dropdown-container-wrapper">';
  $output .= '<div class="ctools-dropdown-container">';
  $output .= theme_links($links);
  $output .= '</div>';

  // container
  $output .= '</div>';

  // container wrapper
  $output .= '</div>';

  // dropdown
  return $output;
}