Reputation: 1
I'm a newbie. How to pass parameters and based on them create a condition in markup? I have such a component
{% component 'demoTodo' %}
but I want to use it in two variations, if mobile = true, then another markup, if false another
{% component 'demoTodo' mobile=true %}
or {% component 'demoTodo' mobile=false %}
{% if mobile == true %}
...
{% else %
...
{% endif %}
How can this be done?
Upvotes: 0
Views: 146
Reputation: 9693
You need to pass component property
and retrieve it in onRender
method and again need to pass it to markup.
You can follow this process to get mobile
variable to your markup
.
Your page markup where you include
component
with propertymobile
{% component 'demoTodo' mobile=true|false %}
Inside your
demoTodo
componentphp
code
function onRender() {
$this->page['mobile'] = $this->property('mobile');
}
in your component's
default.htm
markup normobile
variable will be available
{% if mobile == true %}
...
{% else %
...
{% endif %}
if any doubt please comment.
Upvotes: 1