You are here

function theme_slick_slide in Slick Carousel 7.3

Returns HTML for a slick slide.

Parameters

array $variables: An associative array containing:

  • attributes: An array of attributes to apply to the element.
  • content_attributes: An array of attributes for the inner element.
  • delta: An index of the current item.
  • item containing:
    • slide: A renderable array of the main image/background.
    • caption: A renderable array containing caption fields if provided:
      • title: The individual slide title.
      • alt: The core Image field Alt as caption.
      • link: The slide links or buttons.
      • overlay: The image/audio/video overlay, or a nested slick.
      • data: Any possible field for more complex data if crazy enough.
  • settings: An array containing the given settings.
1 theme call to theme_slick_slide()
template_preprocess_slick_grid in templates/slick.theme.inc
Prepares variables for theme_slick_grid().

File

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

Code

function theme_slick_slide(array $variables) {
  extract($variables);
  $slide = empty($item['slide']) ? '' : drupal_render($item['slide']);
  if ($slide && $settings['split'] && empty($settings['unslick'])) {
    $slide = '<div class="slide__media">' . $slide . '</div>';
  }
  $caption = '';

  // Ensures no caption markup is displayed until its data is provided.
  if ($settings['use_caption']) {
    $inner = empty($item['caption']['title']) ? '' : '<h2 class="slide__title">' . drupal_render($item['caption']['title']) . '</h2>';
    $inner .= empty($item['caption']['alt']) ? '' : '<p class="slide__description">' . drupal_render($item['caption']['alt']) . '</p>';
    $inner .= empty($item['caption']['data']) ? '' : '<div class="slide__description">' . drupal_render($item['caption']['data']) . '</div>';
    $inner .= empty($item['caption']['link']) ? '' : '<div class="slide__link">' . drupal_render($item['caption']['link']) . '</div>';

    // Third level overlay container can be nested slicks, or videos.
    if (empty($item['caption']['overlay'])) {
      $caption = $inner;
    }
    else {
      $caption = '<div class="slide__overlay">' . drupal_render($item['caption']['overlay']) . '</div>';

      // Prevents overlay (nested slicks) from overlapping individual caption.
      if ($settings['has_data']) {
        $caption .= '<div class="slide__data">' . $inner . '</div>';
      }
    }

    // Second level caption container.
    $caption = '<div' . $caption_attributes . '>' . $caption . '</div>';

    // First level caption fullwidth container.
    if ($settings['fullwidth']) {
      $caption = '<div class="slide__constrained">' . $caption . '</div>';
    }
  }

  // Put slide and caption together, and only wrap with extra divs as required.
  // We should have bare minimum markups until required at the cost of ifities.
  // The same applies to CSS classes. By default slick has only two CSS classes.
  $build = $slide . $caption;
  if ($settings['use_wrapper']) {

    // Second level slide container.
    if (empty($settings['grid'])) {
      $build = '<div' . $content_attributes . '>' . $build . '</div>';
    }

    // First level slide container.
    $build = '<div' . $attributes . '>' . $build . '</div>';
  }
  return $build;
}