I have been trying different things but no luck so far. My sites use Garland theme with the front page being a teaser list plus the left and right sidebars. I want the front page to have Google ads in the left and right sidebars as well as word wrapped on the first and only the first teaser.

Right now Adsense + injector modules cannot deal with this. I set it up with the adense generated blocks. If I put one block in the left sidebar and one in the right and enable the teaser list option in adsense injector it will put ads in the first 3 teasers only. Don't know if this happens on Googles end because they limit to 3 pages or if Adsense module knows to only allow 3.

So what I want it to do is only inject an ad in the first and ONLY the first teaser. That way the ads in the left and right side bars will also show up. I tried some php snippets in the block visiblity and adsense visibility sections but no luck.

Anyone know of a php snippet or some other way to limit adsense injector visibility to ONLY the first teaser of the teaser list?

Comments

mustardman’s picture

Ok I managed to figure out a simple kludge to get around this. Looking in adsense.module file near the bottom it turns out the module does in fact check if Adsense has reached it's limits.

/**
 * Determine if AdSense has reached limit on this page. As per Google's
 * policies, a page can have up to 3 ad units and 3 link units.
 *
 * @return
 *   TRUE if we can insert another ad, FALSE if not allowed.
 */
function _adsense_can_insert_another($type = ADSENSE_TYPE_AD) {
  static $num_ads = array(
    ADSENSE_TYPE_AD     => 0,
    ADSENSE_TYPE_LINK   => 0,
    ADSENSE_TYPE_SEARCH => 0,
  );

  $max_ads = array(
    ADSENSE_TYPE_AD     => 3,
    ADSENSE_TYPE_LINK   => 3,
    ADSENSE_TYPE_SEARCH => 2,
  );

  if ($num_ads[$type] < $max_ads[$type]) {
    $num_ads[$type]++;
    return TRUE;
  }

  return FALSE;
}

I simply changed the $max_ads =array to 1, 1, 1

So that limits the ads shown in the node teasers front page and on individual nodes to 1 using adsense module+injector. I then used a block on both sidebars to show Google Ads without implementing the adsense module.

It seems to me it would be relatively easy to make a hook to the admin menu which would expose this setting and allow it to be changed from 3 to 2 or 1 but I'm not a coder.

jcnventura’s picture

Status: Active » Closed (won't fix)

Hi,

First of all, this is a feature you'd like to see in the adsense injector module.. And this is the adsense module. Please ask for this feature there.

In #1, you're asking for a hook to change the max ads array to something else, when these values are provided by Google and certainly don't need to be changed at all. What you did by inserting some ads using the module and some directly may in the future end up in you breaking Adsense's ToS and showing more than 3 ads in a page.

For that reason, I don't see anything in the module needing to be changed.

mustardman’s picture

Category: feature » support

I am not a coder but because it is adsense.module that limits the ads and creates the adsense blocks would it not be the adsense.module where I would submit a feature request?

Right now the Google imposed 3 ad limit coded into adsense.module is too feature limited for my use. I am using in content ads plus 2 sidebar block ads. Adsense.module is not intelligent enough to know there are 2 adsense blocks configured and enabled and to only allow 1 in content ad + 2 block ads. Right now it is 3 ads total whatever comes first. So in the case of how Drupal works what comes first is the teaser list on the default front page. So ads are shown on the first 3 teasers instead of the first teaser + 2 sidebar blocks.

Then again, perhaps a feature in the adsense injector teaser list admin setting which specifies how many teaser nodes up to 3? Not sure which makes more sense from a coder point of view. A bit over my head.

mustardman’s picture

Category: support » feature