vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   vb:if condition problem (https://vborg.vbsupport.ru/showthread.php?t=231033)

MaryTheG(r)eek 12-24-2009 05:25 AM

vb:if condition problem
 
Hello all,

Does anybody knows what's wrong with:
Code:

<vb:if condition="{vb:raw item_premium}==1">checked</vb:if>
Thank you in advance
Maria

BBR-APBT 12-24-2009 01:45 PM

Code:

<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

Quote:

Originally Posted by BBR-APBT (Post 1937270)
Code:

<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

Quote:

Originally Posted by MicroHellas (Post 1937319)
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

Quote:

Originally Posted by BBR-APBT (Post 1937270)
Code:

<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

Quote:

Originally Posted by James Birkett (Post 1937934)
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.


All times are GMT. The time now is 07:13 AM.

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.01313 seconds
  • Memory Usage 1,731KB
  • 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
  • (4)bbcode_code_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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