You are here

function template_preprocess_flexslider_list in Flex Slider 8.2

Prepares variables for flexslider list template.

Default template: flexslider-list.html.twig.

File

templates/flexslider.theme.inc, line 101
Theming functions for the flexslider module.

Code

function template_preprocess_flexslider_list(&$variables) {

  // Reference configuration variables.
  $optionset =& $variables['settings']['optionset'];
  $items =& $variables['items'];
  $attributes =& $variables['attributes'];

  // @todo find a way to detect the outer container class if possible
  $attributes['class'][] = 'slides';

  // Build the list.
  $variables['content']['list'] = [];
  if (!empty($items)) {
    foreach ($items as $i => $item) {
      $caption = '';
      if (!empty($item['caption'])) {
        $caption = $item['caption'];
      }

      // Add the list item render array.
      $variables['content']['list'][$i] = [
        '#theme' => 'flexslider_list_item',
        '#item' => $item['slide'],
        '#settings' => [
          'optionset' => $optionset,
        ],
        '#caption' => $caption,
      ];
    }
  }
}