vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How many conditionals is too many? (https://vborg.vbsupport.ru/showthread.php?t=206514)

Azonaco 02-24-2009 11:14 PM

How many conditionals is too many?
 
I'm thinking about adding about 40-50 conditionals based on different forum ID's that would target advertising based on that particular section of the forum. Since I have 40-50 total forums, there would be quite a few conditionals.

1. Does this produce lag for browsers?

2. Does this eat away precious resources like cpu or memory for my server?

Thanks in advance!

1Unreal 02-24-2009 11:16 PM

The conditionals are server side so it will only effect your server. And, depending on what is contained within the condition it will depend. But generally speaking it should be ok.

Azonaco 02-24-2009 11:53 PM

Thanks, one more question...

The only thing contained within the conditional is an amazon widget script. I've narrowed it down to 8 total conditionals. Each conditional will have 5-10 forum IDs but only one will be generated in each section of my forum. Does this sound ok?

1Unreal 02-25-2009 12:10 AM

Yeah thats fine. Remember that <if></if>'s are the same as if() {}'s in PHP.

nexialys 02-25-2009 01:29 AM

your best shot will be to create a plugin that will call the right ads instead of creating much conditionals in a template...

read here: http://ca2.php.net/manual/en/control...res.switch.php .. about switches. one single conditional, you change the $i to the $forumid ... each forumid will determine which Ads will show, and a default one can be shown if no $forumid... etc!

1Unreal 02-25-2009 04:02 AM

Doing what Nexialys said is probably best, switches make things alot cleaner it terms of code. However either way will appear seemless to the user as switches are just a collection of if statements formed into a more coherent structure.

Dismounted 02-25-2009 07:38 AM

Quote:

Originally Posted by 1Unreal (Post 1753779)
Yeah thats fine. Remember that <if></if>'s are the same as if() {}'s in PHP.

Template conditionals are actually interpreted into the ternary operator (that's why you can't do elseif's).

Azonaco 02-25-2009 10:58 PM

Thanks everyone

1Unreal 02-25-2009 11:04 PM

Quote:

Originally Posted by Dismounted (Post 1754027)
Template conditionals are actually interpreted into the ternary operator (that's why you can't do elseif's).

Whatever that means :p

I find vB amazing how it interprets the templates.

Dismounted 02-27-2009 11:34 AM

PHP Code:

// this is an if/else conditional
if ($something)
{
    
// do something
}
else
{
    
// do something else
}

// this is the ternary operator
($something) ? dosomething() : dosomethingelse(); 


1Unreal 02-27-2009 11:53 AM

Ooo...Didn't know that existed.

Actually, that makes something a bit easier in one of my scripts. Thanks ;)

Dismounted 02-27-2009 11:55 AM

Remember to not overuse it - the code should still be readable.


All times are GMT. The time now is 10:29 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.00987 seconds
  • Memory Usage 1,733KB
  • 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
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (12)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