You are here

function theme_slick in Slick Carousel 7.3

Returns HTML for a slick.

Parameters

array $variables: An associative array containing:

  • items: The array of items containing main image/video/audio, optional image/video/audio overlay and captions, and optional thumbnail texts/images.
  • js: The JS optionset which may contain configurable HTML such as arrows.
  • settings: A cherry-picked settings that mostly defines the slide HTML or layout, and few JS settings/options which affect HTML output.
  • attributes: The attributes to hold the main container classes, RTL, id.
  • content_attributes: The array of attributes to hold optional id and data-slick containing JSON object aka JS settings the Slick expects to override default options. We don't store these JS settings in the normal <head>, but inline within data-slick attribute instead.
1 theme call to theme_slick()
SlickManager::slick in src/SlickManager.php
Returns a cacheable renderable array of a single slick instance.

File

templates/slick.theme.inc, line 130
Hooks and preprocess functions for the Slick module.

Code

function theme_slick(array $variables) {
  extract($variables);

  // Prevents direct call to this theme without proper checks from screwing up.
  // @todo remove babysitters at Slick 4.x.
  if (empty($items)) {
    return '';
  }

  // Unslick is when slides amount is less than slidesToShow that is when the
  // slideshow cannot slide. The markups are only provided when it can slide.
  if (empty($settings['unslick'])) {
    $arrow_down = empty($arrow_down_attributes) ? '' : '<button' . $arrow_down_attributes . '></button>';
    $arrows = '<button type="button" data-role="none" class="slick-prev" aria-label="' . $js['prevArrow'] . '" tabindex="0">' . $js['prevArrow'] . '</button>';
    $arrows .= $arrow_down;
    $arrows .= '<button type="button" data-role="none" class="slick-next" aria-label="' . $js['nextArrow'] . '" tabindex="0">' . $js['nextArrow'] . '</button>';
    $items = [
      'slides' => $items,
    ];
    $items['slides']['#prefix'] = '<div' . $content_attributes . '>';
    $items['slides']['#suffix'] = '</div><nav' . $arrow_attributes . '>' . $arrows . '</nav>';
  }
  $build = [
    'content' => $items,
  ];
  $build['content']['#prefix'] = '<div' . $attributes . '>';
  $build['content']['#suffix'] = '</div>';
  return drupal_render_children($build);
}