Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-10-2004, 07:10 PM
baze22 baze22 is offline
 
Join Date: Apr 2002
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Question about Conditionals

I'm trying to get adsense integrated into my forum. I only want the ads showing in showthread displays and forumdisplays and I want to exclude certain (non-public) forums. I've used the following:

Code:
<if condition="THIS_SCRIPT == 'showthread' || THIS_SCRIPT == 'forumdisplay'">
<if condition="(f <> 6) && (f <> 7)">
ad here
</if>
</if>
It restricts it to the page but still shows for all forums. I'm not sure of the right variable name to use for the forumid (I have tried forumid). Is there a list somewhere listing variables available to use in the conditional statements.

thanks,

basil
Reply With Quote
  #2  
Old 08-10-2004, 07:11 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you'll have to use $f for sure, but I would use $forumid instead. Or even $foruminfo[forumid]
Reply With Quote
  #3  
Old 08-10-2004, 08:16 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by baze22
I'm trying to get adsense integrated into my forum. I only want the ads showing in showthread displays and forumdisplays and I want to exclude certain (non-public) forums. I've used the following:

Code:
<if condition="THIS_SCRIPT == 'showthread' || THIS_SCRIPT == 'forumdisplay'">
<if condition="(f <> 6) && (f <> 7)">
ad here
</if>
</if>
It restricts it to the page but still shows for all forums. I'm not sure of the right variable name to use for the forumid (I have tried forumid). Is there a list somewhere listing variables available to use in the conditional statements.

thanks,

basil
Try this. In PHPINCLUDE_START place this in by itself

PHP Code:
$display_ad false;

if (
$foruminfo['forumid']) // This determines if we are in a forum at all.
                                //  If we're not in a forum this evaluates false.
     
{
           if (
$foruminfo['forumid']<>'6' AND $foruminfo['forumid']<>'7')
             {
$display_ad true;}
     } 
Later on you can add forums to the list of adless forums by adding to the second conditional.

Meanwhile, back in whatever template is getting this ad simply put

HTML Code:
<if conditional="$display_ad">ad</if>

Footnote, the f=# you see on the top bar isn't a variable, but it is contained in one; $_GET. You shouldn't go calling $_GET inside your templates though - it might leave your setup vulnerable to certain hacks.
Reply With Quote
  #4  
Old 08-11-2004, 01:08 PM
baze22 baze22 is offline
 
Join Date: Apr 2002
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Michael_Morris
Try this. In PHPINCLUDE_START place this in by itself

Later on you can add forums to the list of adless forums by adding to the second conditional.

Meanwhile, back in whatever template is getting this ad simply put

HTML Code:
<if conditional="$display_ad">ad</if>

Footnote, the f=# you see on the top bar isn't a variable, but it is contained in one; $_GET. You shouldn't go calling $_GET inside your templates though - it might leave your setup vulnerable to certain hacks.
Thanks for the help. I see that I might have been closer if I had remembered to put the $ in front of my variable names. I like your solution better. I did go ahead and make my PHPINCLUDE_START code like this:
PHP Code:
$display_ad FALSE
if (
THIS_SCRIPT == 'showthread' || THIS_SCRIPT == 'forumdisplay')
     { 
           if (
$foruminfo['forumid']<>'6' AND $foruminfo['forumid']<>'7'
             {
$display_ad true;} 
     } 
The way you had it still had the ads showing on other pages, like during a reply or new thread.

On a side note - You had me pulling my hair out trying to get your code to work. Looked like it should have worked great. Problem was that the ad was showing on EVERY page not even all forum diplay pages. Turns out that in you code above you put "conditionAL". That made it look like $display_ad was true every time. Once I cleared out the AL it worked great. Thanks again.

basil
Reply With Quote
  #5  
Old 08-11-2004, 03:53 PM
baze22 baze22 is offline
 
Join Date: Apr 2002
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I did make one final change before I put on the production site, changed the PHPSTART code to:
PHP Code:
$display_ad FALSE
$omit_forums = array(6,7);
if (
THIS_SCRIPT == 'showthread' || THIS_SCRIPT == 'forumdisplay')
     { 
           if (!
in_array($foruminfo['forumid'],$omit_forums)) 
             {
$display_ad true;} 
     } 
This way when I want to add forums not to be included, I just add them to the $omit_forums array, I can also use it if I want to exclude things from those forums in future mods.

Thanks again for responses,

basil
Reply With Quote
  #6  
Old 08-11-2004, 07:01 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by baze22
Thanks for the help. I see that I might have been closer if I had remembered to put the $ in front of my variable names. I like your solution better. I did go ahead and make my PHPINCLUDE_START code like this:
PHP Code:
$display_ad FALSE
if (
THIS_SCRIPT == 'showthread' || THIS_SCRIPT == 'forumdisplay')
     { 
           if (
$foruminfo['forumid']<>'6' AND $foruminfo['forumid']<>'7'
             {
$display_ad true;} 
     } 
The way you had it still had the ads showing on other pages, like during a reply or new thread.

On a side note - You had me pulling my hair out trying to get your code to work. Looked like it should have worked great. Problem was that the ad was showing on EVERY page not even all forum diplay pages. Turns out that in you code above you put "conditionAL". That made it look like $display_ad was true every time. Once I cleared out the AL it worked great. Thanks again.

basil
Sorry about that - I typed it off the top of my head and didn't test it for errors. Next time I'll check my work.
Reply With Quote
  #7  
Old 11-29-2004, 03:56 PM
todd222222 todd222222 is offline
 
Join Date: Mar 2003
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have tried to set this up but for some reason the ads are being displayed on forums I choose to omit....is this what you ended up putting in production?

Thanks,
Todd
Reply With Quote
  #8  
Old 11-29-2004, 04:00 PM
todd222222 todd222222 is offline
 
Join Date: Mar 2003
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nevermind, it's actually showing on everypage.....back to the drawing board.

Thanks,
Todd
Reply With Quote
  #9  
Old 12-02-2005, 05:30 PM
ConqSoft's Avatar
ConqSoft ConqSoft is offline
 
Join Date: Jul 2003
Location: Raleigh, NC
Posts: 686
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Kinda related to this, so this looks like a good place to ask.

Anyone know the syntax to replace a lot of OR's with something like:

IF THIS_SCRIPT IN ('name1','name2','name3')

Instead of:
Code:
<if condition="THIS_SCRIPT == 'showthread' OR THIS_SCRIPT == 'forumdisplay' OR THIS_SCRIPT == 'index' OR THIS_SCRIPT == 'member' OR THIS_SCRIPT == 'memberlist' OR THIS_SCRIPT == 'search'">
Reply With Quote
  #10  
Old 05-25-2006, 09:11 AM
doozyj doozyj is offline
 
Join Date: Apr 2006
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Michael Morris
Sorry about that - I typed it off the top of my head and didn't test it for errors. Next time I'll check my work.
Could you tell me where to place this script exactly and does this need to include the Google Adsense code?
What if I have 2 different codes that need to be omitted?

Thanks for your help in advance?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:40 AM.


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.06875 seconds
  • Memory Usage 2,278KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_html
  • (4)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete