Добавить модальное всплывающее окно рассылки на домашнюю страницу CMS


Я сделал всплывающее окно, подобное этому

<?php
    $newsletterHtml = $block->getChildHtml('subscribe');
?>

<div id="custom-popup-modal">
    <div class="col-sm-6">
        <div class="static_content">
            <h5 class="min-title-bold">JOIN THE PARTY</h5>
            <h2 class="min-title-large">GET 15% OFF YOUR FIRST ORDER*</h2>
            <p class="small-content">Subscribers only discounts, first look at new products, and cutting-edges tips</p>
            <?php echo $newsletterHtml; ?>
            <p class="micro-text">*Promo code will be emailed to the address you enter, New subscribers only</p>
        </div>
    </div>
    <div class="col-sm-6 img-section">
        <!-- <button id="Cross-popup"   class="" type="button" data-role="action"><span>X</span></button> -->

        <img src='<?php echo $this->getUrl('pub/media/').'cms/image-email.gif'; ?>' />
    </div>
</div>

<script type="text/javascript" xml="space">

    require(['jquery','Magento_Ui/js/modal/modal'],

        function($,modal) {

            var options = {
                type: 'popup',
                responsive: true,
            };

            var popup = modal(options, $('#custom-popup-modal'));
            $( document ).ready(function() {
                $('#custom-popup-modal').modal('openModal');
            });
        }
    );

</script>

Теперь я хочу добавить это на главную страницу. Я понятия не имел, как я могу добавить его. используя блок? тогда я не знаю, как назначить этот код для блокировки.

Author: Abhishek Panchal, 2017-11-28

1 answers

Попробуйте выполнить код ниже. Убедитесь, что jQuery загружается на домашнюю страницу. Вы можете добавить любое изображение с помощью редактора WYSIWYG.

<div id="custom-popup-modal">
    <div class="col-sm-6">
        <div class="static_content">
            <h5 class="min-title-bold">JOIN THE PARTY</h5>
            <h2 class="min-title-large">GET 15% OFF YOUR FIRST ORDER*</h2>
            <p class="small-content">Subscribers only discounts, first look at new products, and cutting-edges tips</p>
            {{block class="Magento\Newsletter\Block\Subscribe" name="static.newsletter" template="Magento_Newsletter::subscribe.phtml"}}
            <p class="micro-text">*Promo code will be emailed to the address you enter, New subscribers only</p>
        </div>
    </div>
    <div class="col-sm-6 img-section">
        <img src='' /> <!-- add image by WYSIWYG editor -->
    </div>
</div>

<script type="text/javascript" xml="space">
    require(['jquery','Magento_Ui/js/modal/modal'],
        function($,modal) {
            var options = {
                type: 'popup',
                responsive: true,
            };
            var popup = modal(options, $('#custom-popup-modal'));
            $( document ).ready(function() {
                $('#custom-popup-modal').modal('openModal');
            });
        }
    );
</script>
 6
Author: Abhishek Panchal, 2017-11-28 14:42:02