Answer the question
In order to leave comments, you need to log in
How to create a variable in Twig and assign it a value from another variable?
{% if mpn %} // если есть переменная
{{ mpn }} // то вывожу ее
{% set collectionname = '{{mpn}}' %} // и устанавливаю новую переменную, присвоив ей значение из переменной "{{ mpn }}"
коллекция - {{ collectionname }} - // но в итоге выводится не само значение, а голый прям текст - {{ mpn }}
{% endif %}
Answer the question
In order to leave comments, you need to log in
For those who came here with the same question:
when setting a variable and assigning it a value from another variable, you need to specify the variable from which we want to get the value. without quotes and brackets
Incorrect:
Correct:
{% set collectionname = '{{mpn}}' %}
{% set collectionname = mpn %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question