PDA

View Full Version : Can you do if conditions based on the =action and not just THIS_SCRIPT?


greigeh
04-18-2016, 07:01 PM
title says it all, i'm sure you can but not sure on the condition

Dr.CustUmz
04-18-2016, 08:42 PM
if ($_REQUEST['do'] == 'action') {
Do this
} else {
Do that
}

is this what you mean?

greigeh
04-19-2016, 03:11 PM
if ($_REQUEST['do'] == 'action') {
Do this
} else {
Do that
}

is this what you mean?

This is technically what i mean, but is that string not available as a pre-made if condition? cause to me that looks like to be used in a script or something.

squidsk
04-19-2016, 03:52 PM
If you're trying to do something in a template then just put the condition part of the if statement in the quotes of the condition attribute of the if tag otherwise.


<if condition="$_REQUEST['do'] == 'action'">
<else />
<endif>


Of course your template would be far neater if you set a the value you wanted output in the script (based on the condition) and then just had the template output the final value.

Dr.CustUmz
04-19-2016, 06:10 PM
This is technically what i mean, but is that string not available as a pre-made if condition? cause to me that looks like to be used in a script or something.

just for learning =) what i posted is a real if condition, what vbulletin uses is it's own variation of php / html so

in php
if ($_REQUEST['do'] == 'action') {
Do this
} else {
Do that
}

or even better:
($_REQUEST['do'] == 'action') ? (Do this) : (Do that)

is the same as
vBulletin php/html
<if condition="$_REQUEST['do'] == 'action'">
do this
<else />
do that
</if>

all 3 blocks of code are the same and its good to know these ways for plugins / templates