The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
I need help with an IF conditional...
Okay, here's the scenario - I have a section of code in one of the PHP files that sets a variable to either true or false, for example:
PHP Code:
Now, I want a section in one of the vB Templates to be able to pull from that so that if $custom_variable was set to true, than a section of code would execute (and if it's false, it would not) - for example: Code:
<if condition="$custom_variable"> <!-- Insert Code to be executed here --> </if> However, the template portion of the code isn't working for me. So the question is - what am I doing wrong? |
#2
|
||||
|
||||
What you've done seems fine, but keep in mind you can't "execute" any code in the templates. It's plain html that goes there, besides the variables and the conditional system.
|
#3
|
||||
|
||||
Quote:
Is the problem that the variable in the PHP code needs to be defined or declared previously? Because either there is a problem with that variable, or the template IF statement can't read it properly. |
#4
|
|||
|
|||
Quote:
<if condition="$FOO==1 AND $FOO = 2"> would set $FOO to 2 if it was equal to 1. I would bet one can hide any PHP one wanted in conditionals, with just a little trickery. |
#5
|
||||
|
||||
CarCdr,
i was referring to the "Insert Code to be executed here" part of his statement, which is between if tags. Ocean, is the variable defined BEFORE the template is evaluated? Also, check it's value by just adding echo $custom_variable; exit; after the if. |
#6
|
|||
|
|||
work this out with the vB iif:
PHP Code:
PHP Code:
|
#7
|
||||
|
||||
Okay, problem solved. My original code should have worked just fine - the text editor I happened to use once added an additional hidden character to a Paste function, which effectively made it so that the variable being set in the PHP file was not the same variable being called by the template code.
I hate it when problems of this nature surface. Ai. Thank you, everyone, for your help. |
#8
|
||||
|
||||
That's why notepad rocks.
|
#9
|
||||
|
||||
Quote:
It's the one time I deviated from that, that I got burned. Well, that will be the last time that happens. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|