You are here

function theme_jcarousel in jCarousel 6.2

Same name and namespace in other branches
  1. 8.3 jcarousel.module \theme_jcarousel()
  2. 6 jcarousel.module \theme_jcarousel()
  3. 7.3 jcarousel.module \theme_jcarousel()
  4. 7.2 jcarousel.module \theme_jcarousel()

Creates a jCarousel element on the page.

Parameters

$items: The items to appear in the carousel.

$options: The arguments to apply to the selected element when creating the jCarousel. The arguments are passed through as an associative array using the jCarousel configuration options: http://sorgalla.com/projects/jcarousel/#Configuration

The special option "skin" may also be specified to use any skin provided by jcarousel_skins() and hook_jcarousel_skin_info().

$id: An ID for this carousel. If not provided, one will be generated automatically. Note that this is not the "id" attribute on the HTML list, instead it is one of the classes added to the UL tag.

1 theme call to theme_jcarousel()
jcarousel_help in ./jcarousel.module
Implements hook_help().

File

./jcarousel.module, line 325
Provides integration with 3rd party modules and the jCarousel library.

Code

function theme_jcarousel($items = array(), $options = array(), $identifier = NULL) {
  static $unique;
  if (!isset($identifier)) {
    $unique = isset($unique) ? $unique + 1 : 1;
    $identifier = 'jcarousel-id-' . $unique;
  }
  $options['skin'] = array_key_exists('skin', $options) ? $options['skin'] : 'default';
  jcarousel_add($identifier, $options);
  $classes = 'jcarousel ' . $identifier;
  if (!empty($options['skin'])) {
    $classes .= ' jcarousel-skin-' . $options['skin'];
  }
  $output = '<ul class="' . $classes . '">';
  if (is_array($items)) {
    foreach ($items as $item) {
      $output .= '<li>' . $item . '</li>';
    }
  }
  $output .= '</ul>';
  return $output;
}