I am currently using adsense and revenue_sharing_basic modules and I have difficulties using them.
When I use the [adsense:120x240:1:1] tags in the content in order to display ads, the client id is always the same, the main site id.
Caching is disabled on the site. I know that it must be disabled with sharing.
I created the cck field, set it up in the adsense settings and the author of the node has set his adsense client id in his account.
Unfortunatly, the code thinks I supplied a slot id (but I did not) and therefor does not try to get the author's client id.

In the file adsense.module on line 389 I see:

 // If site Slot ID for this ad was passed, pass the format as argument
 // in case Publisher ID modules are enabled that can return different
 // Slot IDs per ad format
 $client_id_arg = isset($args['slot']) ? $args['format'] : NULL;
 $client = adsense_get_client_slot_id($client_id_arg);

If the slot id was passed as an empty value (""), then would you still consider the format to be used as the arg to adsense_get_client_slot_id()?
The revenue_sharing_basic module does not work when a format is being passed:

 if (isset($format)) {
 // This module can't handle the selection of an appropriate Slot ID
 // Give up!
 return NULL;
 }

When I use the adsense injector module, the function is being called from tags like [adsense:120x240:1:1] and this in turn calls adsense_display() with slot as an empty value. The isset() function returns TRUE when the value is empty string. It thinks the slotid was passed when it was NOT.

I think it would make more sense to use !empty() instead of isset().

Here is the patch:

--- sites/all/modules/contrib/adsense/adsense.module~ 2008年09月16日 08:48:06.000000000 -0400
+++ sites/all/modules/contrib/adsense/adsense.module 2008年09月17日 08:16:17.000000000 -0400
@@ -395,7 +395,7 @@ function adsense_display() {
 // If site Slot ID for this ad was passed, pass the format as argument
 // in case Publisher ID modules are enabled that can return different
 // Slot IDs per ad format
- $client_id_arg = isset($args['slot']) ? $args['format'] : NULL;
+ $client_id_arg = !empty($args['slot']) ? $args['format'] : NULL;
 $client = adsense_get_client_slot_id($client_id_arg);
 if (is_array($client)) {

Am I missing something?

CommentFileSizeAuthor
adsense.patch 641 bytesroychri

Comments

jcnventura’s picture

Comment #1

jcnventura
Primary language English
commented
Status: Active » Fixed

Hi,

Thanks for the contribution. I just committed this code.

João

Comment #2

Status: Fixed » Closed (fixed)

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