vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   vBulletin Template Conditionals (https://vborg.vbsupport.ru/showthread.php?t=215032)

nikki712 02-03-2011 03:07 PM

I'm sorry to be a pain, but this is what I used and the ads are still showing up on every forum. I have one particular forum where sponsors answer questions. This forum as an "Ask the Expert" forum with several child forums dedicated to each individual expert. I don't want ads for competitors showing up there. What is wrong with my code now? I have included the "Ask the Expert" forum ID, along with the IDs for all the child forums. Ads cannot show up in these forums, and I don't want the "experts" usergroup to see any at ads at all...on any forum.

Code:

<center><if condition="!in_array($forum['forumid'], array(32,48,34,44,41,49,53,58,61,79,82,81,80,46,52,36,40)) AND !is_member_of($vbulletin->userinfo, 7,14)"><script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxx";
/* Forum Leaderboard */
google_ad_slot = "xxxxxxxxx";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></if></center>


BirdOPrey5 02-03-2011 03:18 PM

Where are you putting this code?

Some places user different variables, instead of $forum['forumid'] try $thread['forumid'] or $foruminfo['forumdid'] or $threadinfo['forumid'] (if you're in a thread).

nikki712 02-03-2011 03:28 PM

I've tested it on ad_navbar_below.

--------------- Added [DATE]1296756776[/DATE] at [TIME]1296756776[/TIME] ---------------

When I try the $foruminfo['forumdid'] code, the ad shows up as "page cannot be displayed". I'm gonna try the other two suggestions and see if they work.

BirdOPrey5 02-03-2011 04:42 PM

Quote:

Originally Posted by nikki712 (Post 2158277)
I've tested it on ad_navbar_below.

--------------- Added [DATE]1296756776[/DATE] at [TIME]1296756776[/TIME] ---------------

When I try the $foruminfo['forumdid'] code, the ad shows up as "page cannot be displayed". I'm gonna try the other two suggestions and see if they work.

It's $foruminfo then... if there's a problem the ad can't be shown that's an unrelated issue - a problem with your ad code.

nikki712 02-03-2011 04:53 PM

None of these seem to work. I'm so frustrated b/c I've had a server load problem and have narrowed it down to the Adsense hack I have installed. I'm hoping to find a workaround for this by using these conditionals, but they don't want to cooperate with me. :(

--------------- Added [DATE]1296759302[/DATE] at [TIME]1296759302[/TIME] ---------------

The problem is that even though it said "page cannot be displayed", it was still showing up in a forum that it shouldn't be in. I made a test user and put it in the "experts" usergroup, and could see all ads.

--------------- Added [DATE]1296759410[/DATE] at [TIME]1296759410[/TIME] ---------------

I'm just going to try to get it to not show up in the experts forum, and forget about blocking ads throughout the entire forum for my experts group.

BirdOPrey5 02-03-2011 04:59 PM

I just tested this on my forum, it's definitely $foruminfo['forumid'] to show the ad code in specific forums (forumdisplay) and threads in that forum (showthread.)

If you get the page can't be displayed message in the ad box you have an error in the code you copied from google to show the ad. The fact that the box shows means the conditional is working.

nikki712 02-03-2011 07:06 PM

I don't know what I'm doing wrong, but if you don't mind, can you please take a look at my code and see if anything looks wrong? I'm copying the code directly from Google. My hack works fine, but I disable it to test out the conditionals.

Code:

<if condition="!in_array($foruminfo['forumid'], array(32,48,34,44,41,49,53,58,61,79,82,81,80,46,52,36,40))"><script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxx";
/* Forum Leaderboard */
google_ad_slot = "xxxxxxxxxxx";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></if>

32,48,34,44,41,49,53,58,61,79,82,81,80,46,52,36,40 - Forum IDs I DON'T want ads shown in.

Also, could my PHP version be the problem? I'm running 5.2.16.

--------------- Added [DATE]1296771156[/DATE] at [TIME]1296771156[/TIME] ---------------

The answer is to use $GLOBALS instead of $foruminfo. Works like a charm!

BirdOPrey5 02-03-2011 08:13 PM

I copied your code into my forum and the condition works perfectly fine for me (in the ad_navbar_below template) which is shown in the navbar template...

What exactly isn't working? I can't test the google code obviously but it looks like it should work if you had numbers in place of the x's.

DO you have a kink to a forum this is running on?

nikki712 02-03-2011 10:29 PM

Nope, no kinks. This code works:

Code:

<if condition="!in_array($GLOBALS['forumid'], array(32,48,34,44,41,49,53,58,61,79,82,81,80,46,52,36,40))"> AND <if condition="!is_member_of($vbulletin->userinfo, 1,2)">
Zachary at vb.com helped me out. He said to make them two separate conditionals like this:

Code:

<if condition="!is_member_of($bbuserinfo, 14)>
<if condition="!in_array($GLOBALS[forumid], array(32,48,34,44,41,49,53,58,61,79,82,81,80,46,52,36,40))">
ADD CODE HERE
</if>
</if>

I haven't tried the last code, but will a little later on. I'll let you know how it goes. Thanks!!! :)

--------------- Added [DATE]1296779481[/DATE] at [TIME]1296779481[/TIME] ---------------

Oh, the problem was that the ads were showing up in the forums I didn't want them to show up in. They were also showing up to the usergroups I didn't want them showing up to. The "page cannot be displayed" was just a glitch with one of the image ads. That's all that was.

PAKIDIL 02-28-2011 02:12 PM

i have problem in conditional coding too .

i am pasting this in one of my template ad location ad_showthread_firstpost

<if condition="THIS_SCRIPT != 'adv_index' AND THIS_SCRIPT != 'register' AND $GLOBALS[forumid] != 6">

and getting this error

Parse error: syntax error, unexpected ',' in /home/forum/public_html/includes/adminfunctions_template.php(3772) : eval()'d code on line 1

can anyone help ?.


All times are GMT. The time now is 11:39 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02332 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete