Hi,
Using GPT JS code for responsive tags, for example :
<script async='async' src='https://www.googletagservices.com/tag/js/gpt.js'></script>
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
</script>
<script>
googletag.cmd.push(function() {
var mapping = googletag.sizeMapping().
addSize([1280, 0], [[728, 90], [468, 60]]).
addSize([980, 0], [468, 60]).
addSize([600, 0], [320, 50]).
build();
googletag.defineSlot('/12345678/OC3-lbgc1', [[728, 90], [320, 50], [468, 60]], 'div-gpt-ad-12345678901234-0').
defineSizeMapping(mapping).
addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
I have a problem whenever there is a [[ in the code (ex , [[728, 90], [320, 50], [468, 60]],) since i guess MODX processes it and it is not rendered.
Is there a way to prevent Modx from parsing this JS code ?
I found a first fix using such a snippet :
<?php
$pubid = (int) $modx->getOption('pubid', $scriptProperties);
$resource = $modx->getObject('modResource',$pubid);
$output= $resource->get('content');
return $modx->regClientStartupScript($output);
when placed in a resource content to get the JS script above the </head> tag.
However when using for instance :
<?php
$pubid = (int) $modx->getOption('pubid', $scriptProperties);
$resource = $modx->getObject('modResource',$pubid);
$output= $resource->get('content');
return $output;
to use it in a template (pubid being the id# of the JS resource with the appropriate Google JS code) it
doesn't work !
I get
googletag.defineSlot('/12345678/OC3-lbgc1', , 'div-gpt-ad-12345678901234-0').
instead of
googletag.defineSlot('/12345678/OC3-lbgc1', [[728, 90], [320, 50], [468, 60]], 'div-gpt-ad-12345678901234-0').
so the Google code is broken.
Any idea ?
Thanks !