Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-24-2009, 05:25 AM
MaryTheG(r)eek MaryTheG(r)eek is offline
 
Join Date: Sep 2006
Location: Greece
Posts: 1,340
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 12-24-2009, 01:45 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 12-24-2009, 02:31 PM
MaryTheG(r)eek MaryTheG(r)eek is offline
 
Join Date: Sep 2006
Location: Greece
Posts: 1,340
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BBR-APBT View Post
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
Reply With Quote
  #4  
Old 12-25-2009, 11:21 AM
consolegaming consolegaming is offline
 
Join Date: Jan 2007
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MicroHellas View Post
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.
Reply With Quote
  #5  
Old 12-25-2009, 12:02 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BBR-APBT View Post
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").
Reply With Quote
  #6  
Old 12-26-2009, 05:40 PM
consolegaming consolegaming is offline
 
Join Date: Jan 2007
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by James Birkett View Post
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.
Reply With Quote
  #7  
Old 12-26-2009, 10:36 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 12-26-2009, 10:49 PM
consolegaming consolegaming is offline
 
Join Date: Jan 2007
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:45 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.04220 seconds
  • Memory Usage 2,232KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete