The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
"Nested" conditionals, help with optimising working postbit modification please.
Gone
|
#2
|
||||
|
||||
what you could do is nest it a little better
as you have the condiition $userinfo[field13] != '' almost everywhere, why not make that one conditional? and from there go in. <if condition="$userinfo[field13] != ''> <if condition="$userinfo[field13] != 'MINI Cooper Convertible'"> and so on... |
#3
|
||||
|
||||
Code:
<if condition="$car != ''"> <if condition="$roof == 'black'"> <if condition="$paint == 'red'"> <a href="#">redblack</a> <else /> <if condition="$paint == 'blue'"> <a href="#">blueblack</a> </if> </if> what might be easier for you though is to make buttons with the specific color. so if you want an image to show for the blue-red car, name this image bluered.gif and call it up with $userinfo[field5]$userinfo[field6].gif That should work... just make a check for if there's no data entered. |
#4
|
|||
|
|||
Yikes!
If I understand, the only thing you are figuring out is which GIF to output, since that looks to be the only difference in the <a> tags you are generating. One thing you could do is get rid of all the common tests. For example, your first group of tests, the first 18, are identical except for 2nd last test where you are checking field23 for specific colours. So, for each group, start the group with the test for the common tests, then each test within the group will have only a single test. Here is an example from that first group of 18 tests: Code:
<if condition="$userinfo[field13] != '' AND $userinfo[field13] != 'MINI Cooper Convertible' AND $userinfo[field13] != 'MINI One Convertible' AND $userinfo[field13] != 'MINI Cooper S Convertible' AND $userinfo[field24] != 'Black' AND $userinfo[field24] != 'Body Color' AND $userinfo[field24] != 'Other' AND $userinfo[field25] != ''> <if condition="$userinfo[field23] == 'Solid Black'"> u s e t h i s G I F... </if> <else /><if condition="$userinfo[field23] == 'Cosmos Black'"> u s e t h i s G I F... </if> ... <else /> n e x t g r o u p ... |
#5
|
|||
|
|||
If your want to do this on the PHP side, you can use associative arrays. To initialize the arrays you would use something like this for each entry:
Code:
$car_gifs['Mini Cooper S']['Black']['Chili Red'] = 'gif_name.gif'; Later, when you want to output a gif, you can do this: Code:
$the_gif = $car_gifs["$model"]["$body"]["$color"]; if (empty($the_gif)) { $the_gif = $My_Default_Gif; } |
#6
|
|||
|
|||
Your first if conditional is missing a closing double-quote for condition=""
|
#7
|
|||
|
|||
You still have duplicated tests. Perhaps the logic is wrong, not the syntax.
For example, your first group begins with a long test that includes AND $userinfo[field25] != '' yet within that group, you repeat the test for 'Dark Silver' and 'Electric Blue' -- the last two tests of the first group. |
#8
|
|||
|
|||
Removing the extra "25" field tests should not change anything. We know it is true because you entered the first group, therefore we know it will be true when we test it inside the group.
I am suggesting that your logic is wrong -- what you intend to do is not reflected in the code. Those extra tests hint that you are trying to do something else that is not possible with the tests you have there now. Explain in plain language what you are trying to do in that first group and we'll go from there. |
#9
|
||||
|
||||
OK, I went through the whole thing for you.
If I didn't forget an </if> or anything else anywhere, this should work.... Code:
<!-- start MINIs --> <if condition="$userinfo[field25] != ''"> <if condition="$userinfo[field13] != ''"> <if condition="$userinfo[field24] != 'Other' AND $userinfo[field24] != 'White'"> <if condition="$userinfo[field13] != 'MINI Cooper Convertible' AND $userinfo[field13] != 'MINI One Convertible' AND $userinfo[field13] != 'MINI Cooper S Convertible' AND $userinfo[field24] != 'Black' AND $userinfo[field24] != 'Body Color' AND $userinfo[field24] != 'Other'"> <if condition="$userinfo[field23] == 'Solid Black' OR 'Cosmos Black' OR 'Astro Black'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/black.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Chili Red'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/red.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Liquid Yellow'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/yellow.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Pepper White'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/pw.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Velvet Red'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/vr.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'British Racing Green'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/brg.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Solid Gold Met'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/gold.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Silk Green'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/sg.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Indi Blue'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/indi.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Hyper Blue'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/hyper.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Black-Eye Purple'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/bep.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Pure Silver'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/ps.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Dark Silver'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/ds.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Electric Blue'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/elec.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> <else /> <if condition="$userinfo[field24] != 'Body Color'"> <if condition="$userinfo[field23] == 'Cosmos Black' OR 'Solid Black' OR 'Astro Black'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/blackblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Chili Red'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/redblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Liquid Yellow'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/yellowblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Pepper White'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/pwblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Velvet Red'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/blackblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'British Racing Green'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/brgblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Solid Gold Met'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/goldblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Silk Green'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/sgblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Indi Blue'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/indiblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Hyper Blue'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/hyperblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Black-Eye Purple'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/bepblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Pure Silver'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/psblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Dark Silver'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/dsblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Electric Blue'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/elecblack.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> (have to split it up, newreply.php is timing out on me) |
#10
|
||||
|
||||
second part:
Code:
<else /> <if condition="$userinfo[field24] != 'Black'"> <if condition="$userinfo[field23] == 'Cosmos Black' OR 'Solid Black' OR 'Astro Black'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/blackone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Chili Red'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/redone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Liquid Yellow'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/yellowone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Pepper White'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/pwone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Velvet Red'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/blackone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'British Racing Green'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/brgone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Solid Gold Met'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/goldone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Silk Green'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/sgone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Indi Blue'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/indione.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Hyper Blue'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/hyperone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Black-Eye Purple'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/bepone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Pure Silver'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/psone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Dark Silver'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/dsone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Electric Blue'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/elecone.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> </if> <else /> <if condition="$userinfo[field23] != '' AND $userinfo[field24] == 'Other'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/apple.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> </if> <else /> <if condition="$userinfo[field24] != '' AND $userinfo[field23] == 'Other'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/apple.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> </if> </if> </if> <else /> <if condition="$userinfo[field23] == 'Hot Orange'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/orange.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> <else /> <if condition="$userinfo[field23] == 'Cool Blue'"> <a href="member.php?u=$post[userid]&do=vehicledetails" target="_blank"><img src="techtwo/cars/coolb.gif" border="0" alt="mini_button.gif" title="View $userinfo[username]'s $userinfo[field13] Profile" /></a> </if> </if> </if> </if> <!-- end MINIs --> |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|