You are here

function _jcarousel_help_vertical in jCarousel 8.4

Same name and namespace in other branches
  1. 8.5 jcarousel.module \_jcarousel_help_vertical()
1 call to _jcarousel_help_vertical()
jcarousel_help in ./jcarousel.module
Implements hook_help().

File

./jcarousel.module, line 136
Provides integration with 3rd party modules and the jCarousel library.

Code

function _jcarousel_help_vertical() {
  $build = [];
  $details = [
    '#type' => 'details',
    '#title' => t('View sample code'),
    '#description' => t('Following PHP code must be run to add the jCarousel library and CSS to the page.'),
  ];
  $build[] = [
    '#type' => 'html_tag',
    '#tag' => 'h3',
    '#value' => t('Vertical carousel'),
  ];
  $build[] = [
    '#type' => 'html_tag',
    '#tag' => 'p',
    '#value' => t('jCarousel can accept a variety of <a href=":url">configuration options</a> via #options arguments in render array. In this example, we created a vertical carousel.', [
      ':url' => 'http://sorgalla.com/projects/jcarousel/#Configuration',
    ]),
  ];
  $images = _jcarousel_help_image_list();
  $options = [
    'vertical' => TRUE,
    'auto' => 2,
    'autoPause' => TRUE,
    'wrap' => 'circular',
    'events' => [
      'jcarousel' => [
        'jcarousel:create' => 'jcarousel.createCarousel',
      ],
    ],
  ];
  $build['jcourusel'] = _jcarousel_help_render_gen($images, $options);
  $build['jcourusel_sample'] = $details;
  $code = "<?php\n      \$output = '';\n      \$renderer = \\Drupal::service('renderer');\n       \$images = [\n        'http://sorgalla.com/jcarousel/examples/_shared/img/img1.jpg',\n        'http://sorgalla.com/jcarousel/examples/_shared/img/img2.jpg',\n        'http://sorgalla.com/jcarousel/examples/_shared/img/img3.jpg',\n        'http://sorgalla.com/jcarousel/examples/_shared/img/img4.jpg',\n        'http://sorgalla.com/jcarousel/examples/_shared/img/img5.jpg',\n        'http://sorgalla.com/jcarousel/examples/_shared/img/img6.jpg',\n      ];\n      \$items_list = [];\n      foreach (\$images as \$image) {\n        \$items_list[] = [\n          '#theme' => 'image',\n          '#uri' => \$image,\n          '#width' => '150px',\n          '#height' => '100px',\n          '#alt' => t('Image alt'),\n        ];\n      }\n      \$options = [\n        'vertical' => TRUE,\n        'auto' => 2,\n        'autoPause' => TRUE,\n        'wrap' => 'circular',\n        'events' => [\n          'jcarousel' => [\n            'jcarousel:create' => 'jcarousel.createCarousel',\n          ],\n        ],\n      ];\n      \$jcourusel = [\n        '#theme' => 'jcarousel',\n        '#options' => \$options,\n        '#items' => \$items_list,\n      ];\n      \$output .= \$renderer->render(\$jcourusel);\n?>";
  $build['jcourusel_sample']['sample'] = [
    '#type' => 'inline_template',
    '#template' => '{{ php_code|raw }}',
    '#context' => [
      'php_code' => highlight_string($code, TRUE),
    ],
  ];
  return $build;
}