Ad

Display Other Partial Than Default.htm In Component OnRun Method

- 1 answer

How to display other partial than default.htm in onRun component method ? have to test some stuff and display specific partial according to the result.

edit: Another important point is that one of these partials need specific data, so how to pass them

Ad

Answer

You can simply check some condition in twig and then include the correct partial in your default.htm. Example:

{% if __SELF__.someCondition %}

    {% partial __SELF__ ~ '::file1' %}

{% else %}

    {% partial __SELF__ ~ '::file2' %}

{% endif %}

Where someCondition refers to either a member variable of your component or a method. You can even have more complex structures and check for certain values explicitly. Check out the twig documentation.

Ad
source: stackoverflow.com
Ad