vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   HTML <if>? (https://vborg.vbsupport.ru/showthread.php?t=200477)

MTGDarkness 01-02-2009 09:11 PM

HTML <if>?
 
How do you use this? I can't find any guides, or indeed anything about the <if> tag anywhere outside the actual code of forum software itself! I'm trying to work an if clause into a template modification (iTrader based), and I just need to know the correct usage of <if>... Does it have to be
HTML Code:

<if condition=>(code)</if>
? Or could it be
HTML Code:

<if $var=$var2>(code)</if>
?

And what about else options?

TriggerHappy123 01-02-2009 11:25 PM

I'm not sure if html has if's but javascript does. this may help, you can integrate it with html.

Kirk Y 01-02-2009 11:27 PM

The syntax is:
Code:

<if condition="CONDITION">Displayed when CONDITION is TRUE</if>
This is a vBulletin-only HTML "tag" -- it is parsed out by PHP when the template is evaluated. You can't just throw it in an HTML document.

MTGDarkness 01-02-2009 11:29 PM

That's what I thought. But all the time I see
Code:

<if condition=$var>(stuff to do)</if>
, and that makes no sense to me...

Kirk Y 01-02-2009 11:32 PM

In PHP, $var is the same as isset($var) which returns TRUE if $var exists and FALSE if it does not.

So--
Code:

<if condition="$var">Stuff to do</if>
Will display "Stuff to do" when $var exists.

MTGDarkness 01-03-2009 12:01 AM

Oh, I see. Thanks. I'm going to try out my template modification and see if it works...

sparklywater 01-03-2009 12:04 AM

see this tutorial for vB conditionals: http://www.vbulletin.com/docs/html/

type in 'template conditionals' in the search box and click on first link.

Adrian Schneider 01-03-2009 12:24 AM

The condition between the two quotes is parsed as a boolean expression.

Quote:

Originally Posted by PHP Manual
When converting to boolean, the following values are considered FALSE:
  • the boolean FALSE itself
  • the integer 0 (zero)
  • the float 0.0 (zero)
  • the empty string, and the string "0"
  • an array with zero elements
  • an object with zero member variables (PHP 4 only)
  • the special type NULL (including unset variables)
  • SimpleXML objects created from empty tags
Every other value is considered TRUE (including any resource).

Usually in templates, you'd check the value of options or user settings. Unless you really understand the above, it's best to use comparisons to avoid mix ups.

Code:

<if condition="$variable == 'Yes'">
<if condition="$variable > 10">
<if condition="$vbulletin->options['something_enabled']">

etc.

MTGDarkness 01-03-2009 12:37 AM

Thanks for the help guys. Modification works great. :)


All times are GMT. The time now is 02:18 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.02468 seconds
  • Memory Usage 1,732KB
  • 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
  • (2)bbcode_html_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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