vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Question about Conditionals (https://vborg.vbsupport.ru/showthread.php?t=68205)

baze22 08-10-2004 07:10 PM

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

Colin F 08-10-2004 07:11 PM

you'll have to use $f for sure, but I would use $forumid instead. Or even $foruminfo[forumid]

Michael Morris 08-10-2004 08:16 PM

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.

baze22 08-11-2004 01:08 PM

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. :D Once I cleared out the AL it worked great. Thanks again.

basil

baze22 08-11-2004 03:53 PM

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

Michael Morris 08-11-2004 07:01 PM

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. :D 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.

todd222222 11-29-2004 03:56 PM

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

todd222222 11-29-2004 04:00 PM

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

Thanks,
Todd

ConqSoft 12-02-2005 05:30 PM

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'">

doozyj 05-25-2006 09:11 AM

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?


All times are GMT. The time now is 06:22 AM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01275 seconds
  • Memory Usage 1,761KB
  • 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
  • (3)bbcode_code_printable
  • (2)bbcode_html_printable
  • (4)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete