You are here

function _jcarousel_help_simple in jCarousel 8.4

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

File

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

Code

function _jcarousel_help_simple() {
  $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('Horizontal carousel'),
  ];
  $build[] = [
    '#type' => 'html_tag',
    '#tag' => 'p',
    '#value' => t('This example uses Drupal 8 render API with no jcarousel options to create the default horizontal carousel.'),
  ];
  $images = _jcarousel_help_image_list();
  $build['jcourusel'] = _jcarousel_help_render_gen($images);
  $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      \$jcourusel = [\n        '#theme' => 'jcarousel',\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;
}