Z
Z
zzamzam2016-11-23 10:29:30
Angular
zzamzam, 2016-11-23 10:29:30

How to pass adsense code from php to angular or js?

Website on ZF2. Adsense codes are set in the admin panel, which are displayed in the template . I see two ways: 1. We make a hidden block in the template where we display the code
<?=$adsenseCodeMiddle['code_value']?>

<div id="adsense-code" style="display: none">
    <?=$adsenseCodeMiddle['code_value']?>
</div>

then we take its content, paste it in the right place and display an ad block in its place
var adsense_code = $('#adsense-code').html();
var adblock = [
    '<div class="adblock">',
        + adsense_code +
    '</div>'
].join("\n");
$('.account-item-last').after(adblock);
(adsbygoogle = window.adsbygoogle || []).push({});

2. Pull code with ajax
How else can this be done and what is the most correct way?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question