You are here

function _jcarousel_help_skins in jCarousel 8.4

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

File

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

Code

function _jcarousel_help_skins() {
  $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('Different skins'),
  ];
  $build[] = [
    '#type' => 'html_tag',
    '#tag' => 'p',
    '#value' => t('The "skin" of a carousel can be changed by setting the <code>$options[\'skin\']</code> property. This skin must match one of the skins either provided by a module or matching a skin included in your theme\'s style.css file. Skins are simply a class given to the HTML list with the name "jcarousel-skin-[skin-name]". A custom skin path may be specified in <code>$options[\'skin path\']</code>, or you can use one of these module-based skins:'),
  ];
  $skins = \Drupal::service('jcarousel.skins.manager')
    ->getDefinitions();
  $build['skin_list'] = [
    '#theme' => 'item_list',
    '#items' => array_keys($skins),
  ];
  $build[] = [
    '#type' => 'html_tag',
    '#tag' => 'p',
    '#value' => t("Note that with skins you will often need to override certain\n    CSS styles in your theme's style.css file. Certain properties (like the\n    height and width of individual items and the carousel itself) must be\n    manually specified directly in CSS. You can create own skin in module or\n    theme by adding mymodule_or_theme_name.jcarousel_skins.yml file with folowing content\n    <code><pre>\n    myskin:\n      label: 'My Skin'\n      file: assets/vendor/jcarousel/skins/myskin/jcarousel-myskin.css\n      weight: 1</pre></code>"),
  ];
  $images = _jcarousel_help_image_list();
  $options = [
    'skin' => 'tango',
  ];
  $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        'skin' => 'tango',\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;
}