0

So i wrote this piece of code, and it works if i remove the echo and outside php. But inside php, it wont show. I suspect it has something to do with "data-mage-init="{promo_popup:{}}". Anybody has an idea what to do or to solve it?

if($Popup_enable == 1){
echo '<div class="news-popup" data-mage-init="{`promo_popup`:{}}" >
    <div class="container">
        <div class="row justify-content-between no-gutters">
            <div class="col-11 col-md-9">
                <p>
                    <span class="alert-message d-inline-block font-weight-bold px-3 py-2">
                        '.$Popup_text.'
                    </span>
                </p>
                <p>
                    '.$Popup_b_text.'
                </p>
            </div>
            <div class="col-1 col-md-auto text-right">
                <button type="button" class="btn btn-link btn-close inside-stroke-white-popup display-5">×</button>
            </div>
        </div>
    </div>
</div>';
}
0

It can be fix like this

    echo '<div class="news-popup" id="news-popup" data-mage-init=\'{"promo_popup":{}}\' >
    <div class="container">
        <div class="row justify-content-between no-gutters">
            <div class="col-11 col-md-9">
                <p>
                    <span class="alert-message d-inline-block font-weight-bold px-3 py-2">
                        '.$Popup_text.'
                    </span>
                </p>
                <p>
                    '.$Popup_b_text.'
                </p>
            </div>
            <div class="col-1 col-md-auto text-right">
                <button type="button" class="btn btn-link btn-close inside-stroke-white-popup display-5">×</button>
            </div>
        </div>
    </div>
</div>';

Just put "" before "'"

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.