Home > Back-end >  Disable swiper.js autoplay using inline if statement
Disable swiper.js autoplay using inline if statement

Time:09-22

Im trying to disable the swiper autoplay depending on a widget name parameter that gets me the a value. (Im using magento widget and i get the value from the widget.xml) Here is a example:

simulateTouch: <?= ($block->getData('is_gestures') == "1") ?'true':'false'?>,
               // ---- gestures end -----
            freeMode: true,
                    // --- infinite loop -----
            loop: <?= ($block->getData('infiniteLoop') == "1") ?'true':'false'?>,
                    // --- autoplay ----
             autoplay: {
              delay: 2500,
              disableOnInteraction: false,
             },

with the other values its easy because its a true of false but in this case i need that code to appear if my $block->getData('autoplay') == "1" but i cant figure out how to do it i tried

<?= ($block->getData(‘autoplay’) == "1") ?{  delay: 2500,  disableOnInteraction: false,  },:''?>, or with the code inside '' but it bugs my swiper all the time

CodePudding user response:

<?= ($block->getData(‘autoplay’) == "1") ?'{  delay: 2500,  disableOnInteraction: false,  }':'false'?>,

The solution was wrapping the code that belongs to autoplay == 1 in '' and before the : is false and it works that way

  • Related