You are here

function template_preprocess_slick_grid in Slick Carousel 7.2

Same name and namespace in other branches
  1. 8.2 templates/slick.theme.inc \template_preprocess_slick_grid()
  2. 8 templates/slick.theme.inc \template_preprocess_slick_grid()
  3. 7.3 templates/slick.theme.inc \template_preprocess_slick_grid()

Implements hook_preprocess_slick_grid().

File

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

Code

function template_preprocess_slick_grid(&$variables) {
  $element = $variables['element'];
  $settings = $element['#settings'];
  $attributes =& $variables['attributes_array'];
  $attributes = array(
    'class' => array(
      'slick__grid',
      'block-grid',
    ),
  );
  if (empty($settings['unslick'])) {
    $attributes['class'][] = 'slide__content';
  }
  $settings['grid_large'] = $settings['grid'];
  foreach (array(
    'small',
    'medium',
    'large',
  ) as $grid) {
    if ($column = $settings['grid_' . $grid]) {
      $attributes['class'][] = $grid . '-block-grid-' . $column;
    }
  }
  $variables['items'] = array();
  foreach ($element['#items'] as $delta => $item) {
    $settings['current_item'] = 'grid';
    $settings = isset($item['settings']) ? array_merge($settings, $item['settings']) : $settings;
    $classes = array(
      'slide__grid',
      'grid',
      'grid--' . $delta,
    );
    $variables['item_attributes_array'][$delta]['class'] = $classes;
    $slide['slide'] = array(
      '#theme' => 'slick_item',
      '#item' => isset($item['slide']) ? $item['slide'] : $item,
      '#caption' => empty($item['caption']) ? array() : array_filter($item['caption']),
      '#delta' => $delta,
      '#settings' => $settings,
    );
    $variables['items'][$delta] = $slide;
    unset($slide);
  }
  $variables['classes_array'] = $attributes['class'];
}