You are here

function hook_slick_settings_alter in Slick Carousel 7.3

Same name and namespace in other branches
  1. 8.2 slick.api.php \hook_slick_settings_alter()
  2. 8 slick.api.php \hook_slick_settings_alter()

Modifies Slick HTML settings before being passed to preprocess, or templates.

If you need to override globally to be inherited by all blazy-related modules: slick, gridstack, mason, etc., consider hook_blazy_settings_alter().

Parameters

array $build: The array containing: item, content, settings, or optional captions.

object $items: The \Drupal\Core\Field\FieldItemListInterface items.

See also

\Drupal\blazy\BlazyFormatter::buildSettings()

\Drupal\slick\SlickFormatter::buildSettings()

Related topics

1 invocation of hook_slick_settings_alter()
SlickFormatter::preBuildElements in src/SlickFormatter.php

File

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

Code

function hook_slick_settings_alter(array &$build, $items) {
  $settings =& $build['settings'];

  // See blazy_blazy_settings_alter() at blazy.module for existing samples.
  // First check the $settings array. Slick Views may have different array.
  if (isset($settings['entity_id'])) {

    // Change skin if meeting a particular criteria.
    if ($settings['optionset'] == 'x_slick_for') {
      $settings['skin'] = $settings['entity_id'] == 54 ? 'fullwidth' : $settings['skin'];
    }

    // Swap optionset at particular pages.
    if (in_array($settings['entity_id'], [
      54,
      64,
      74,
    ])) {
      $settings['optionset'] == 'my_slick_pages';
    }
  }
}