By default Drupal displays a node teaser list as the front page. My front page using Garland Theme displays the default node teaser list front page with Google Adsense ad blocks in the left and right sidebars.

I have adsense injector configured to inject google ads in page and teaser list. The problem is that there is no way to limit how many Teaser nodes the ad displays in. So whatever I configure for Google ads using the adsense injector teaser list setting will be repeated in the first 3 node teasers at which point the Google ad limit is reached and no further ads will be displayed on the sidebars of the front page.

I just want to display an ad in the first and only first node teaser. That way my 2 sidebar ads will also be displayed on the front page. How I do this currently is change the google ad limit from 3 to 1 in adsense.module. This allows only 1 ad on teaser lists and pages. My sidebar ads will then also display on all the pages.

I think it would be useful if adsense injector had a feature that allows an administrator to determine how many of the 3 ads can be allowed on pages vs node teasers. So for example one could configure injector to insert up to 2 ads on pages + 1 ad on node teasers or visa versa.

Perhaps someone has a code snippet I could use directly in the injector template that counts node teasers and allows me to do it that way? Doing it via the GUI with no code needed would obviously be preferrable for the code challenged like me.

Comments

zakjan’s picture

Status: Active » Needs work

My quick solution: open adsense_injector.module and change lines 45-46 to this:

if (!$GLOBALS['adsense_injector_inline_count']) {
  $GLOBALS['adsense_injector_inline_count'] = 0;
} 
if ($GLOBALS['adsense_injector_inline_count'] < 2) {
  $template = _adsense_process_tags(variable_get('adsense_injector_list_view_template', '%teaser<br class="clear"/>[adsense:728x90:0123456789]'));
  $node->teaser = strtr($template, array('%teaser' => $node->teaser));
  $GLOBALS['adsense_injector_inline_count']++;
}
mustardman’s picture

Thanks, I'll try that.

whiztech’s picture

subscribe

Greg Boggs’s picture

Version: 6.x-2.7 » 7.x-3.x-dev
Priority: Normal » Major
Status: Needs work » Active

Seems easy to implement and required for the "teaser" display to be of any use. My thought is as a configuration option allowing the limit to be set.

Greg Boggs’s picture

Priority: Major » Critical