Adsense issues - Getting It Off Multiple Site Pages

Started by Dio, July 19, 2005, 06:48:41 PM

Previous topic - Next topic

Dio

Help For A PHP Luddite reuired, to stay inside the Adsense TOS.

I've got thus far. Its fair to say I know very little on PHP - well nothing in fact.

I've dredged through old threads where I found adding this would help to keep the adsense code off the Admin Pages and the Login Page:



if (!isset($context['admin_areas']) && $context['sub_template'] != 'login')
echo '<div align="center" class="tborder">
<script type="text/javascript"><!--
google_ad_client = "pub-0691188711472327";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel ="8678466755";
google_color_border = "FFCCFF";
google_color_bg = "FFCCFF";
google_color_link = "333333";
google_color_url = "333333";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>';



Which works a treat. I want to expand that somewhat so it doesn't appear on post pages and any member profile pages. I'm guessing its something to do with this bit of the code.



$context['sub_template'] != 'login')



And was wondering what the syntax would be to make that for multiple site bits like post - profile etc. Any help appreciated, this is my first ever forum, and its been a breeze so far!
Crazy Frog Fans Forum [nofollow] | Cheesy Movies [nofollow] | Chav Mum [nofollow] | Viral Auctions [nofollow]

That's Welsh Dai-O, Not Ronnie James Day-o

[Unknown]

!in_array($context['sub_template'], array('x', 'y', 'z'))

-[Unknown]

Dio

Can I just confirm, instead of :

if (!isset($context['admin_areas']) && $context['sub_template'] != 'login')

I use


if (!isset($context['admin_areas']) &&  !in_array($context['sub_template'], array('x', 'y', 'z')))


in which case, x y z - is there a list of sub template names I can use there?

I already have 'login' - would it be like 'profile', 'post' ?

Thanks for the help so far
Crazy Frog Fans Forum [nofollow] | Cheesy Movies [nofollow] | Chav Mum [nofollow] | Viral Auctions [nofollow]

That's Welsh Dai-O, Not Ronnie James Day-o

[Unknown]

Yes.  There's no list on hand, but if you tell me what areas you want removed, I can tell you what you can use to remove them.

-[Unknown]

Dio

Awsome - basically, any user profile pages, personal message pages and the post a reply/topic page. I got admin and login covered. ;)
Crazy Frog Fans Forum [nofollow] | Cheesy Movies [nofollow] | Chav Mum [nofollow] | Viral Auctions [nofollow]

That's Welsh Dai-O, Not Ronnie James Day-o

[Unknown]

!in_array('profile', $context['template_layers']) && !isset($context['post_errors'])

Would be the simplest ways to check for those.

-[Unknown]

Dio

Yeah - that's got it suckered. I can stay with in the Adsesne TOS now. Sending a virtual pint or three your way now. :D
Crazy Frog Fans Forum [nofollow] | Cheesy Movies [nofollow] | Chav Mum [nofollow] | Viral Auctions [nofollow]

That's Welsh Dai-O, Not Ronnie James Day-o

icfsindia

Thanks for all the postings of  yours.

What I understand,

Quoteif (!isset($context['admin_areas']) && $context['sub_template'] != 'login')

This will disable google adsense code from functioning in admin pages and login page.
The code is pasted after this statement with a echo' command.


Quote!in_array('profile', $context['template_layers']) &&
!isset($context['post_errors'])

This will  enable you to collect the various sub_template names like login for
login template etc.

But how and where to use this and how to obtain the list of templates.  I did
not understand..


Quoteif (!isset($context['admin_areas']) &&  !in_array($context['sub_template'],
array('x', 'y', 'z')))

This is the code that is to be used to disable the code from more than one
pages, where x, y and z are to be replaced with the relevant names of the
templates related to the pages in which the ads are to be disabled.

Please help me out

Regards
Ratnakar

Gargoyle

Could you please post the entire code for this check that you and [unknown] have done such a good job at figuring for the rest of us to use Dio ?

I have been struggling with this as well and your code would make my life a ton easier.

icfsindia



   // Show the menu here, according to the menu sub template.
   template_menu();

   echo '
         </td>
      </tr>';

// Show ads only in non-mod/admin areas

if (!isset($context['admin_areas']) && $context['sub_template'] != 'login' )
~~~~~Actual content switched off/on by the if() condition~~~~~

   echo '
<tr><td align="center" colspan="2" height="100" valign="bottom" bgcolor="#d0d0d0">

<script type="text/javascript">
google_ad_client = "pub-XXXXXXXXXXX";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_channel ="XXXXXXX";
google_color_border = "d0d0d0";
google_color_bg = "FFFFFF";
google_color_link = "000080";
google_color_url = "005177";
google_color_text = "000000";
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js [nofollow]"> </script>

</td></tr>';
~~~~~End Actual content switched off/on by the if() condition~~~~~

   // Show a random news item? (or you could pick one from news_lines...)
   if (!empty($settings['enable_news']))

Dio

That's about it - but you can use a div align and a set class as well if you like, to add the content in the style of the block the ad appears in.

However, something is going wrong somewhere for me - I'm now getting the code showing in admin areas and login pages, but not in PM and those areas. I wish I knew PHP :(
Crazy Frog Fans Forum [nofollow] | Cheesy Movies [nofollow] | Chav Mum [nofollow] | Viral Auctions [nofollow]

That's Welsh Dai-O, Not Ronnie James Day-o

Gargoyle

Very good! I am off to a great start now!

I am still confused by this one though....
!in_array('profile', $context['template_layers']) && !isset($context['post_errors'])

I tried to implement it but I get errors when I do. I must be missing something.

[Unknown]

Quote from: Gargoyle on August 07, 2005, 12:46:52 PM
Very good! I am off to a great start now!

I am still confused by this one though....
!in_array('profile', $context['template_layers']) && !isset($context['post_errors'])

I tried to implement it but I get errors when I do. I must be missing something.

Instead of:

if (!isset($context['admin_areas']) && $context['sub_template'] != 'login')

Use:

if (!isset($context['admin_areas']) && $context['sub_template'] != 'login' && !in_array('profile', $context['template_layers']) && !isset($context['post_errors']))

-[Unknown]

Gargoyle


Dio

I figured out why it had stopped working for me, and all is fine now (using old verison of the page).  :-X

Except for one last place that I'd like to remove it from. The register pages. Any ideas how? Is there one final switch to add to the above code or is it just causing more nightmares. :)

Then finally I can relax about having adsense on the forum. :)
Crazy Frog Fans Forum [nofollow] | Cheesy Movies [nofollow] | Chav Mum [nofollow] | Viral Auctions [nofollow]

That's Welsh Dai-O, Not Ronnie James Day-o

[Unknown]

For the registration page:

isset($context['require_agreement'])

There are other methods, but that's probably going to stand up best to upgrades.

-[Unknown]

Dio

Thanks once again. I am finally sorted this time... I promise. As far as I can see I'm now totally within the AdSense TOS. :)

I'm sure this info will be of use to quite a few people like myself - thanks for taking the time to help out a newb. :)
Crazy Frog Fans Forum [nofollow] | Cheesy Movies [nofollow] | Chav Mum [nofollow] | Viral Auctions [nofollow]

That's Welsh Dai-O, Not Ronnie James Day-o

icfsindia

Quoteisset($context['require_agreement'])

The above code removed the ads from the search page.

A summary of what I understood.

Quoteif
(!isset($context['admin_areas'])
          --> Specifies all pages accessible only to the admin
$context['sub_template'] != 'login'
          --> Specifies login page
!in_array('profile', $context['template_layers'])
          --> Specifies profile page
!isset($context['post_errors'])
          --> Specifies postage error page
isset($context['require_agreement']))
          --> Specifies search page

What is the code for removing the ads from agreement page.  I think that is the only area that is left to be handled.

I did not read through the google TOS clearly.  Is it a requirement that we eliminate the code from the search page.


icfsindia

Quoteif (!isset($context['admin_areas']) && $context['sub_template'] != 'login' && !in_array('profile', $context['template_layers']) && !isset($context['post_errors']) && isset($context['require_agreement']))

Hi all the code seems to have removed the ads from the calendar page also.

I want the ads to appear on the calendar page.  Is it in any way a violation of googles TOS to make ads appear on the calendar page!!!

Is my analysis that
Quote!in_array('profile', $context['template_layers'])
removes ads from calender, etc correct!!!

icfsindia

#19
Google AdSense Program Policies
Ad Placement

  • Up to three ad units may be displayed on each Web site page.
  • A maximum of two Google AdSense for search boxes may be placed on a page.
  • A single link unit may be placed on each Web site page, in addition to the ad units and search boxes specified above. Link units are considered to be 'Google ads' for purposes of these program policies.
  • No Google ad may be placed on any non-content-based pages. This includes error, login, registration, "thank you" or welcome pages.
  • No Google ad or Google search box may be displayed on any domain parking websites, pop-ups, pop-unders, or in any email.
  • No Google ad may be placed on pages published specifically for the purpose of showing ads, whether or not the page content is relevant.
  • Elements on a page must not obscure any portion of the ads, and the ad colors must be such that any ad elements, including text and URL, are visible.
  • Clicks on Google ads must not result in a new browser window being launched.
Google AdSenseTM Online Standard Terms and Conditions


(v) display any Ad(s) or Link(s) on any error page, on any registration or "thank you" page (e.g., a page that thanks a user after he/she has registered with the applicable Web site), on any chat page, in any email, or on any Web page or any Web site that contains any pornographic, hate-related, violent, or illegal content;

Conclusions

Do not display ads on login, error, registration, thankyou pages.
Where was the restriction relating to displaying ads on admin pages.
however since clicking on ads by the web site publisher himself would amount to fraud, may be it would be convenient to eliminate ads appearing on admin pages.

Advertisement: