News:

Wondering if this will always be free?  See why free is better.

Main Menu

Adsense issues - Getting It Off Multiple Site Pages

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

Previous topic - Next topic

icfsindia

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

this removed ads from all my pages!!!!!!!!!!

icfsindia

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

If       Context is not admin_areas
and   sub_template is not 'login'
and   template_layers is not 'profile'
and   Context is not post_errors
and   Context is not require_agreement

Then do the code below or move away to the next statement.

This worked fine for me for the login, admin, agreement, post and post error pages.

I think that much is what we want

Thank you all for sharing your knowledge.


If someone finds this not functioning, please post the message, since i can also modify my code to enable it to function properly.

regards
ratnakar




Dio

That's it - just to expand it slightly for people



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

echo '
</div>';

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

echo 'html / adsense code here';



As for it not being in Admin areas, they would be termed as non-content. Now, The only thing I'm missing now, after I believed I had it all... Is to get it off the search pages. :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

[Unknown]

!isset($context['search_params'])

Is that what you want?

-[Unknown]

Dio

That didn't work for me, however, it made me go and look in the search template and try this:

!isset($context['simple_search'])

which did work - do you foresee any problem with that? If I knew anything about PHP I could maybe see the potential for making a mod to help with this stuff - tick what pages you want it on etc. I wouldn't know where to start though :(

Thanks again for the help!
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]

I guess the only danger is that that may not show in search administration, where you don't want it to show anyway :P.

-[Unknown]

Dio

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

Dio could you please post your finished code. Thank-you

icfsindia

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

If       Context is not admin_areas
and   sub_template is not 'login'
and   template_layers is not 'profile'
and   Context is not post_errors
and   Context is not require_agreement
and   Context is not search page     [Only search form and not results]


bjp

It's working, but this gives mes errors

8: Undefined index: sub_template
Fichier: /var/www/html/site/smf/Themes/default/index.template.php
Ligne: 274

The line 274 is : && $context['sub_template'] != 'login'


with this code :

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

   echo '
   </div>';
if (!isset($context['admin_areas'])
&& $context['sub_template'] != 'login'
&& !in_array('profile', $context['template_layers'])
&& !isset($context['post_errors'])
&& !isset($context['require_agreement']))

echo '
            <br /><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-1232486685154xxx";
google_alternate_color = "f9f9f9";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel ="0560275031";
google_color_border = "f9f9f9";
google_color_bg = "f9f9f9";
google_color_link = "660000";
google_color_url = "000000";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
            </div></td>
  </tr>
</table>';

bjp

And is it possible to deseable adsense on a private section ?

[Unknown]

Instead of:

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

Use:

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

Private section as in a certain board?  Add:

&& (empty($context['current_board']) || $context['current_board'] != ###)

Where ### is the board's id.

-[Unknown]

bjp


-Scott

After changing this && $context['sub_template'] != 'login' (which was causing an error in the log) to this && isset($context['sub_template']) && $context['sub_template'] != 'login' it won't show on any page  now???



-Scott

[Unknown]

Sorry, you want:

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

Then.

-[Unknown]

bjp

I use this code not to display adsense on some part of my board, i'ts ok

if (!isset($context['admin_areas'])
&& (!isset($context['sub_template']) || $context['sub_template'] != 'login')
&& (empty($context['current_board']) || $context['current_board'] != 4.0)
&& !in_array('profile', $context['template_layers'])
&& !isset($context['post_errors'])
&& !isset($context['require_agreement'])
&& !isset($context['simple_search']))

I do not want to display adsense on boardindex. How to do this ?

Sledgemoto

This should be a sticky. For top and bottom inclusion for 1.1 RC 2


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


   // The main content should go here.
   echo '
   <div id="bodyarea" style="padding: 1ex 0px 2ex 0px;">';
   if (!isset($context['admin_areas'])
&& (!isset($context['sub_template']) || $context['sub_template'] != 'login')
&& (empty($context['current_board']) || $context['current_board'] != 4.0)
&& !in_array('profile', $context['template_layers'])
&& !isset($context['post_errors'])
&& !isset($context['require_agreement'])
&& !isset($context['simple_search']))

echo '
            <br /><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-1053276976865774";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="9826615372";
google_color_border = "000000";
google_color_bg = "F0F0F0";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js [nofollow]">
</script>
            </div></td>
  </tr>
</table>';
}

function template_main_below()
{
   global $context, $settings, $options, $scripturl, $txt;

    echo '
   </div>';
if (!isset($context['admin_areas'])
&& (!isset($context['sub_template']) || $context['sub_template'] != 'login')
&& (empty($context['current_board']) || $context['current_board'] != 4.0)
&& !in_array('profile', $context['template_layers'])
&& !isset($context['post_errors'])
&& !isset($context['require_agreement'])
&& !isset($context['simple_search']))

echo '
            <br /><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-1053276976865774";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="9826615372";
google_color_border = "000000";
google_color_bg = "F0F0F0";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js [nofollow]">
</script>
            </div></td>
  </tr>
</table>';
   

   // Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
   echo '



as seen here http://talkingautosurfs.com [nofollow]

SteveWh

#37
Sorry to resurrect such an old topic, but it's exactly what my question is about.

Instead of specifying a long list of pages where AdSense should not be put, I made a very short list of the pages were I do want it:

Only Board indexes and Topic display pages.

After examining the code, here's the test I came up with:

[Edited: Added 2nd line to eliminate ads from the Modify Message, New Topic, and any error page.]

if ((isset($context['current_topic']) || isset($context['current_board']))
    && !isset($context['message']) && !isset($context['post_errors']))...

It does seem to be accomplishing what it's supposed to, but is there anything about it that is bad?

I'm trying to add the main forum index page to the list without adding anything else, but haven't found a way yet.

Advertisement: