After install slick slider and Slick Views modules on multi-directional site, Slider does not work well on RTL, There is option in slick slider module for RTL sites, but this broke slider on LTR, So we need this an option enabled only on RTL sites, I found this solution. How can accomplish this?


This is possible by implementing template_preprocess_slick

use Drupal\Component\Serialization\Json;

* preprocess variables for slick.html.twig templates.
function template_preprocess_slick(&$variables) {
  $language = \Drupal::languageManager()->getCurrentLanguage();
  if($language->getDirection() == 'rtl') {

    $settings = $variables['content_attributes']->offsetGet('data-slick');
    if(!empty($settings)) {
      $settings = Json::decode($settings->value());
      $settings['rtl'] = true;
      $settings = Json::encode($settings);
      $variables['content_attributes']->setAttribute('data-slick', $settings);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.