When Enable Page Level Ads is checked under the module configuration settings, we get <> printed at the top of the pages.

We have enabled the page level ads only on a few pages /article/*
and set the setting to Show for the listed pages.

How can we remove the <>?

CommentFileSizeAuthor
#7 2948088.patch855 bytestamerzg

Comments

tepelena created an issue. See original summary.

tepelena’s picture

Issue summary: View changes
tepelena’s picture

The problem was that the block was not restricted to specific content type.

tepelena’s picture

Status: Active » Closed (works as designed)
ZapevalovAnton’s picture

What? Restricted to specific content type?

tamerzg’s picture

Status: Closed (works as designed) » Active

This issue is still active and reproduce when you check Page Level Ads checkbox and leave default settings (Page level visibility -> )
Then visit the frontpage and you will see <> printed at the top of the page.

tamerzg’s picture

Status: Active » Needs review
StatusFileSize
new855 bytes

And here is the patch.

Issue is in adsense_page_attachments() where in case of pages which don't include Page Level Ads, an HTML comment is being printed using html_head attachments. However '#tag' property is empty which is wrong. If you look at the documentation (https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...) you can see that #tag requires one of 3 values: - meta, link, script. Having empty #tag value causes Drupal to print <>, which is also a bug.

Its probably not envisioned for use case of printing only HTML comment. Patch changes #tag type to meta, which will print the comment but without having <>. However it will print empty in the header. Maybe instead it would be better to disable the comments?

jcnventura’s picture

Thanks for the patch. I've decided to use 'inline_template' and get rid of the adsense_comment template.

jcnventura’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.