Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

how to use php function: in_array in volt

How to use in_array in volt



You can define variable load function php in volt

        //load function php
        $compiler = $volt->getCompiler();
        //define variable translate
        $compiler->addFunction('in_array', 'in_array');

edited May '16

:) That is true, but there is "native" way (not need function to add) xD. Example in volt (variable menu contain string, tmp_dropdown is array- they can be defined in controller):

{% set tmp_dropdown = ['menu', 'texts', 'broadcasts'] %}
{% set menu = 'texts' %}

{% if menu in tmp_dropdown %}YES{% endif %}