PHP Класс Prado\Web\UI\WebControls\TConditional
TConditional displays appropriate content based on the evaluation result
of a PHP expression specified via {@link setCondition Condition}.
If the result is true, it instantiates the template {@link getTrueTemplate TrueTemplate};
otherwise, the template {@link getFalseTemplate FalseTemplate} is instantiated.
The PHP expression is evaluated right before {@link onInit} stage of the control lifecycle.
Since {@link setCondition Condition} is evaluated at a very early stage, it is recommended
you set {@link setCondition Condition} in template and the expression should not refer to
objects that are available on or after {@link onInit} lifecycle.
A typical usage of TConditional is shown as following:
Login
Logout
TConditional is very light. It instantiates either {@link getTrueTemplate TrueTemplate}
or {@link getFalseTemplate FalseTemplate}, but never both. And the condition is evaluated only once.
Показать файл
Открыть проект
Открытые методы
Описание методов
addParsedObject()
публичный Метод
This method overrides the parent implementation by removing
all contents enclosed in the template tag.
createChildControls()
публичный Метод
This method overrides the parent implementation. It evaluates {@link getCondition Condition}
and instantiate the corresponding template.
getCondition()
публичный Метод
public getCondition ( ) : string |
Результат |
string |
the PHP expression used for determining which template to use. Defaults to 'true', meaning using TrueTemplate. |
getFalseTemplate()
публичный Метод
public getFalseTemplate ( ) : Prado\Web\UI\ITemplate |
Результат |
Prado\Web\UI\ITemplate |
the template applied when {@link getCondition Condition} is false. |
getTrueTemplate()
публичный Метод
public getTrueTemplate ( ) : Prado\Web\UI\ITemplate |
Результат |
Prado\Web\UI\ITemplate |
the template applied when {@link getCondition Condition} is true. |
setCondition()
публичный Метод
The context of the expression is the template control containing TConditional.
setFalseTemplate()
публичный Метод
public setFalseTemplate ( Prado\Web\UI\ITemplate $value ) |
$value |
Prado\Web\UI\ITemplate |
|
setTrueTemplate()
публичный Метод
public setTrueTemplate ( Prado\Web\UI\ITemplate $value ) |
$value |
Prado\Web\UI\ITemplate |
|