View Full Version : Prevent AdSense on Specified Threads
TommyC
09-14-2011, 05:54 PM
Running vBulletin 3.8, and utilizing AIN - Advanced Google Adsense ( https://vborg.vbsupport.ru/showthread.php?t=205713 ).
I'm seeking a way to prevent specified threads from having adsense ads displayed on them.
Does anyone know how this can be accomplished?
Thank you in advance.
TommyC
09-28-2011, 12:09 AM
Bump.
BirdOPrey5
09-28-2011, 12:30 AM
If you had the code in an ad location template you could do this easily with a template conditional, something like:
<if condition="$thread[threadid] != XXXX">
Ad code here
</if>
But I don't know how that specific mod works. You should ask for help with mods in the mod thread itself. People who have it installed (or the developer) would be in the best situation to help you.
TommyC
10-08-2011, 08:31 PM
Thank you very much for the reply.
I decided to abandon the mod and just rely on template edits, using your idea of conditionals, which at first was working great. I setup my first ad block flawlessly (after much trial and error).
Then I move down to the footer, and suddenly it is as if vBulletin is unable to read IDs. That is, if I set a conditional to show the ad only if certain conditions are met, it NEVER displays the ad. If I set the conditional to show the ads with exceptions, it displays the ads EVERYWHERE regardless of the exceptions.
For example...
Using this to show my ads on forum 2:
<if condition="in_array($forum, array(2))">
AD CODE
</if>
Result = no ads displayed on any forum, not even forum 2.
Using this to prevent my ads from showing on forum 2, 3, 4, 5:
<if condition="!in_array($forum, array(2,3,4,5))">
AD CODE
</if>
Result = Ads displayed on EVERY forum, even forum 2,3,4,5
This carries over into other conditionals such as usergroup and threadid.
So to reiterate, one set of conditionals = working flawlessly. Other set appears to ignore IDs.
Why would this be happening? And how would I resolve it?
Thanks in advance.
Lynne
10-08-2011, 08:45 PM
Try $GLOBALS['forumid'] instead.
TommyC
10-08-2011, 09:06 PM
Try $GLOBALS['forumid'] instead.
You are a scholar and a saint, that worked perfect! Thank you very much!
I'm a bit curious though, why is it that my first set of conditionals worked, yet the second set required this different variable? Is it an issue with my template?
I'm not complaining by any means as I'm very happy to have a solution, I'm just very curious.
BirdOPrey5
10-08-2011, 09:20 PM
Different templates have access to different variables... Templates like header and footer are on every page, they need the "$GLOBALS" templates that are just on showthread might work with $thread or $threadinfo, templates that are just on forumdisplay make work with $forum or $forumdisplay.
TommyC
11-21-2011, 06:29 AM
Is it possible to use "AND" with a conditional?
For example:
IF usergroup 3 AND forum id 2 then....
or
IF usergroup 3 AND NOT forum id 4 then ....
I've tried a few variations with no luck.
BirdOPrey5
11-21-2011, 12:12 PM
AND, yes... NOT is !
<if condition="is_member_of($bbuserinfo, 3) AND $GLOBALS[forumid] == 2">
<if condition="is_member_of($bbuserinfo, 3) AND $GLOBALS[forumid] != 4">
TommyC
11-21-2011, 04:29 PM
Thank you very much!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.