View Full Version : vb:if condition problem
MaryTheG(r)eek
12-24-2009, 05:25 AM
Hello all,
Does anybody knows what's wrong with:
<vb:if condition="{vb:raw item_premium}==1">checked</vb:if>
Thank you in advance
Maria
BBR-APBT
12-24-2009, 01:45 PM
<vb:if condition="$item_premium =='1'">CHECKED</vb:if>
OR
<vb:if condition="$item_premium ==1">CHECKED</vb:if>
I don't remember lol but its one of those.
don't forget to register $item_premium.
MaryTheG(r)eek
12-24-2009, 02:31 PM
<vb:if condition="$item_premium =='1'">CHECKED</vb:if>
OR
<vb:if condition="$item_premium ==1">CHECKED</vb:if>
I don't remember lol but its one of those.
don't forget to register $item_premium.
Yes, this syntax is the correct. I tried it and works, but I'm really greatfull for your reply. Finally, as I understood, the syntax vb:raw item_premium is to be used only when we need to print something to screen, while the old way $item_premium is valid for hidden values, condititions, etc.
Merry Christmas to you and to your family
Maria
consolegaming
12-25-2009, 11:21 AM
Yes, this syntax is the correct. I tried it and works, but I'm really greatfull for your reply. Finally, as I understood, the syntax vb:raw item_premium is to be used only when we need to print something to screen, while the old way $item_premium is valid for hidden values, condititions, etc.
Merry Christmas to you and to your family
Maria
Yup, that caught me out too. I'd bet they'll change to that syntax in the future because it doesn't really make sense to have two different types of syntax. It'd be best though if they made it compatible with both to allow some backward compatibility.
James Birkett
12-25-2009, 12:02 PM
<vb:if condition="$item_premium =='1'">CHECKED</vb:if>
OR
<vb:if condition="$item_premium ==1">CHECKED</vb:if>
I don't remember lol but its one of those.
don't forget to register $item_premium.
Yeah, remember that in conditions you use the dollar variable rather than a vb: variable.
Also, the first option would check if $item_premium is equal to the string 1, whereas the second would check if $item_premium is equal to the boolean 1 (i.e. "true").
consolegaming
12-26-2009, 05:40 PM
Yeah, remember that in conditions you use the dollar variable rather than a vb: variable.
Also, the first option would check if $item_premium is equal to the string 1, whereas the second would check if $item_premium is equal to the boolean 1 (i.e. "true").
Wouldn't it only do that if he had three equals? In php I ma under the assumption that == '1' is the same as == 1. You'd need to do === 1 for numbers, === '1' for string and === true for boolean as far as I know.
James Birkett
12-26-2009, 10:36 PM
I've managed to use 2 equals signs for boolean in the past via PHP.
I'm not sure about conditions, but I've used it in PHP before.
consolegaming
12-26-2009, 10:49 PM
It would match booleans yes but it would also match the string or number representation. == in PHP is non type specific. i.e. it looks for values that match without checking the types. You use === if you want to make sure the type is the same as well i.e. both sides of the conditional are boolean or numerical etc. So if you wanted to make sure that something was true but not the number 1 or '1' then you'd need to do: if ($condition === true) because if you just had == then it would match with '1' or 1 too.
I barely ever need to check that the type matches as well but I thought it best to point that out.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.