function template_preprocess_slick_grid in Slick Carousel 8.2
Same name and namespace in other branches
- 8 templates/slick.theme.inc \template_preprocess_slick_grid()
- 7.3 templates/slick.theme.inc \template_preprocess_slick_grid()
- 7.2 templates/slick.theme.inc \template_preprocess_slick_grid()
Prepares variables for slick-grid.html.twig templates.
File
- templates/
slick.theme.inc, line 188 - Hooks and preprocess functions for the Slick module.
Code
function template_preprocess_slick_grid(&$variables) {
$variables['settings'] = $variables['element']['#settings'];
$variables['delta'] = isset($variables['element']['#delta']) ? $variables['element']['#delta'] : 0;
$variables['grid_id'] = 'grid';
$settings = $variables['settings'];
// By default Slick only supports Grid Foundation, adds relevant grid_id for
// optional Style: CSS3 Columns, and probably future flexbox.
if (!empty($settings['style']) && $settings['style'] != 'slick') {
$variables['grid_id'] = $settings['style'];
}
if (!empty($settings['media_switch'])) {
$switch = str_replace('_', '-', $settings['media_switch']);
$variables['attributes']['data-' . $switch . '-gallery'] = TRUE;
}
$variables['items'] = [];
foreach ($variables['element']['#items'] as $delta => $item) {
$settings = isset($item['settings']) ? array_merge($settings, $item['settings']) : $settings;
$settings['current_item'] = 'grid';
$item_attributes = empty($item['attributes']) ? [] : $item['attributes'];
unset($item['settings'], $item['attributes']);
$slide['content'] = [
'#theme' => empty($settings['vanilla']) ? 'slick_slide' : 'slick_vanilla',
'#item' => $item,
'#delta' => $delta,
'#settings' => $settings,
];
$slide['attributes'] = new Attribute($item_attributes);
$variables['items'][$delta] = $slide;
unset($slide);
}
}