dfp-slot-definition-js.html.twig in Doubleclick for Publishers (DFP) 8
Default theme implementation to display a DFP short tag.
Available variables:
- tag: TagView object for a DFP tag.
See also
\Drupal\dfp\View\Tag\TagViewBuilder::buildPreTag()
1 theme call to dfp-slot-definition-js.html.twig
- DfpHtmlResponseAttachmentsProcessor::processAttachments in src/
DfpHtmlResponseAttachmentsProcessor.php - Processes the attachments of a response that has attachments.
File
templates/dfp-slot-definition-js.html.twigView source
- {#
- /**
- * @file
- * Default theme implementation to display a DFP short tag.
- *
- * Available variables:
- * - tag: TagView object for a DFP tag.
- *
- * @see \Drupal\dfp\View\Tag\TagViewBuilder::buildPreTag()
- *
- * @ingroup themeable
- */
- #}
- <script type="text/javascript">
- {% if tag.breakpoints %}
- // Start by defining breakpoints for this ad.
- var mapping = googletag.sizeMapping()
- {% for breakpoint in tag.breakpoints %}
- .addSize({{ breakpoint.browser_size }}, {{ breakpoint.ad_sizes }})
- {% endfor %}
- .build();
- {% endif %}
-
- googletag.slots["{{ tag.id }}"] = googletag.defineSlot("{{ tag.adUnit }}", {{ tag.size|raw }}, "{{ tag.placeholderId }}")
-
- {% if tag.clickUrl %}
- .setClickUrl("{{ tag.clickUrl }}")
- {% endif %}
- .addService(googletag.pubads())
-
- {% if tag.adsenseAdTypes %}
- .set('adsense_ad_types', '{{ tag.adsenseAdTypes }}')
- {% endif %}
-
- {% if tag.adsenseChannelIds %}
- .set('adsense_channel_ids', '{{ tag.adsenseChannelIds }}')
- {% endif %}
-
- {% for key, color in tag.adSenseColors %}
- .set('adsense_{{ key }}_color', '#{{ color|upper }}')
- {% endfor %}
-
- {% for target in tag.targeting %}
- .setTargeting('{{ target.target }}', [
- {%- for value in target.value -%}
- '{{ value }}'{%- if not loop.last -%},{%- endif -%}
- {%- endfor -%}
- ])
- {% endfor %}
- {% if tag.breakpoints %}
- // Apply size mapping when there are breakpoints.
- .defineSizeMapping(mapping)
- {% endif %}
- ;
- </script>