Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-08-2014, 06:58 AM
webducknj webducknj is offline
 
Join Date: Dec 2010
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default vb:if condition with multiple forum ID's??

Hi everyone,

My developer retired and I've been doing site upkeep myself. After adding subforums to a forum area though, the original conditionals are not displaying one particular ad spot correctly. Any help straightening this out would be appreciated.

this is what is currently in the template for the ad display;

<vb:if condition="$vbulletin->GPC['forumid'] == 48"><vb:if condition="in_array($vbulletin->GPC['forumid'], array(48,66,67,-1))"><table width="100%" style="background-color:#ffffff;">

I tried (unsuccessfully) to add three other forum ID's to the "==48" but that didn't work and in the process I think maybe the software tried to accommodate my error by adding the next vb:if condition with the array reference (is that even possible for it to generate code in trying to repair a coding error?)

So what use to be a conditional testing to see if the forum being displayed was 48 in order to place the correct ad, it now needs to test for four different forum ID #'s.

Can someone please explain the correct way to make it test for four different ID's before choosing which ad to run?

Thanks very much.
Bart
Reply With Quote
  #2  
Old 02-08-2014, 09:12 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know of any way the software could generate that code for you. It's more likely that at some point someone added the first condition and forgot to delete the second one, or just left it there (since in this case the second one doesn't do anything when it's inside the first one).

In any case I think you want something like this:
Code:
<vb:if condition="in_array($vbulletin->GPC['forumid'], array(48,66,67,-1))"><table width="100%" style="background-color:#ffffff;">

and make sure 48,66,67,-1 is what you want (I don't know what -1 does). Also, you will have to remove the corresponding </vb:if> (which isn't in the code you posted).
Reply With Quote
  #3  
Old 02-08-2014, 01:18 PM
webducknj webducknj is offline
 
Join Date: Dec 2010
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks for the reply kh99....i've been playing with the code all day and finally got something that i can live with. it's not exactly what i was shooting for but i actually like it more than what i originally had in mind and it was by luck that it's worked out the way that it did!

the site is www.multirotorforums.com and it is the DJI Sub-Forum that I was trying to fix. I wanted to have a DJI full-width banner replace the Droidworx banner in all of the DJI sub-forum areas but I can't figure out all of the conditional statements and how they're nested to make it work. by using the array statement in one of them I've got the DJI banner in all of the subforums along with the droidworx banner which is something i didn't know was possible.

so it worked out in the end even if it's different from what i was trying to do.

thanks again,
bart
Reply With Quote
  #4  
Old 02-08-2014, 02:40 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by webducknj View Post
Hi everyone,

My developer retired and I've been doing site upkeep myself. After adding subforums to a forum area though, the original conditionals are not displaying one particular ad spot correctly. Any help straightening this out would be appreciated.

this is what is currently in the template for the ad display;


<vb:if condition="$vbulletin->GPC['forumid'] == 48"><vb:if condition="in_array($vbulletin->GPC['forumid'], array(48,66,67,-1))"><table width="100%" style="background-color:#ffffff;">

I tried (unsuccessfully) to add three other forum ID's to the "==48" but that didn't work and in the process I think maybe the software tried to accommodate my error by adding the next vb:if condition with the array reference (is that even possible for it to generate code in trying to repair a coding error?)

So what use to be a conditional testing to see if the forum being displayed was 48 in order to place the correct ad, it now needs to test for four different forum ID #'s.

Can someone please explain the correct way to make it test for four different ID's before choosing which ad to run?

Thanks very much.
Bart
For multiple forumids, all you need is the second condition

PHP Code:
<vb:if condition="in_array($vbulletin->GPC['forumid'], array(48,66,67,-1))">
//do stuff
</vb:if> 
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 09:39 PM.


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.04379 seconds
  • Memory Usage 2,194KB
  • Queries Executed 11 (?)
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
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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_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