You are here

function my_module_render_slick in Slick Carousel 7.2

Quick sample #1.

See also

slick_build()

File

./slick.api.php, line 24
Hooks and API provided by the Slick module.

Code

function my_module_render_slick() {
  $element = array();

  // Add items.
  $items = array();

  // Use slick_get_image() to have lazyLoad, or theme_image_style/theme_image.
  // Caption contains: editor, overlay, title, alt, data, link.
  $items[] = array(
    'slide' => '<img src="https://drupal.org/files/One.gif" />',
    'caption' => array(
      'title' => t('Description #1'),
    ),
  );
  $items[] = array(
    'slide' => '<img src="https://drupal.org/files/Two.gif" />',
    'caption' => array(
      'title' => t('Description #2'),
    ),
  );
  $items[] = array(
    'slide' => '<img src="https://drupal.org/files/Three.gif" />',
    'caption' => array(
      'title' => t('Description #3'),
    ),
  );

  // Add options.
  $options = array(
    'autoplay' => TRUE,
    'dots' => TRUE,
    'arrows' => FALSE,
  );

  // Build the slick.
  $element = slick_build($items, $options);

  // The following should also work for defaults as the only required is $items:
  $element = slick_build($items);

  // Render the $element, such as found normally at a .tpl file.
  print render($element);

  // Or simply return the $element if a renderable array is expected.
  return $element;
}