View Full Version : How many conditionals is too many?
Azonaco
02-24-2009, 11:14 PM
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-structures.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
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
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
// 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.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.