You are here

function theme_ctools_dropdown in Chaos Tool Suite (ctools) 7

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

Create a dropdown menu.

Parameters

array $variables: An associative array containing:

  • 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.

Return value

string Returns HTML for a language configuration form.

1 theme call to theme_ctools_dropdown()
ctools_ajax_sample_page in ctools_ajax_sample/ctools_ajax_sample.module
Page callback to display links and render a container for AJAX stuff.

File

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

Code

function theme_ctools_dropdown($vars) {

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