PDA

View Full Version : How to disable an ad from certain pages?


shibby2
08-27-2018, 05:38 PM
Hey guys, just wondering if you could tell me how I could remove Google ads from a certain page? For example, I have Adsense code installed in my NAVBAR template, so it shows the ad on all pages (wherever the navbar template is). I don't want the ad to show on certain pages like the "lost password" page, so how would I go about disabling the ad on that page?

Any help is very appreciated, thanks!

blind-eddie
08-27-2018, 08:18 PM
Add this conditional to your ad code in your navbar template.
<if condition="THIS_SCRIPT != 'login'">
Your ad code
</if>

shibby2
08-27-2018, 10:37 PM
Thanks! But, could you possibly explain a little better for me? I'm not too bright when it comes to this stuff. lol So I'm assuming I would change "THIS_SCRIPT" to the name of the file where I don't want the ads to appear? Also, if there were a few different pages I didn't want ads to run on, how would I do that?

Thanks again so much! :)

MarkFL
08-27-2018, 11:57 PM
Thanks! But, could you possibly explain a little better for me? I'm not too bright when it comes to this stuff. lol So I'm assuming I would change "THIS_SCRIPT" to the name of the file where I don't want the ads to appear? Also, if there were a few different pages I didn't want ads to run on, how would I do that?

Thanks again so much! :)

THIS_SCRIPT is a constant that stores the name of the script being run, for external scripts that define it. So, use Tim's code exactly as is to prevent ads from displaying on the login script.

If you wish to stop ads on multiple scripts, then you could use something like:

<if condition="!in_array(THIS_SCRIPT, array('login', 'script2', 'script3',...))">
Your ad code
</if>

Replace 'script1' and 'script2' with the other scripts on which you want to prevent ads. You can list as many as you desire.

shibby2
08-28-2018, 06:10 AM
Oh ok, gotcha! Thanks so much guys! I'll give it a try tomorrow and let ya know how I made out.

Thanks again! :)

iA1
08-28-2018, 07:32 AM
Try this mod, it should help: https://vbulletin.org/forum/showthread.php?t=326045

blind-eddie
08-28-2018, 09:48 PM
THIS_SCRIPT is a constant that stores the name of the script being run, for external scripts that define it. So, use Tim's code exactly as is to prevent ads from displaying on the login script.

If you wish to stop ads on multiple scripts, then you could use something like:

<if condition="!in_array(THIS_SCRIPT, array('login', 'script2', 'script3',...))">
Your ad code
</if>

Replace 'script1' and 'script2' with the other scripts on which you want to prevent ads. You can list as many as you desire.

https://nacc.club/vbimghost.php?do=displayimg&imgid=1167

shibby2
08-29-2018, 06:57 PM
Thanks so much guys, it works perfectly! :) I'm definitely going to check out that MOD too!

Take care for now!