0

Im writing little CMS, for this project Im using Laravel/Lumen FW and Twig engine for templates. I would like to had option to dynamically edit front page, and her sections. Sections of my front page, are stored in mySQL base as text where I putting my html code of section. Section is printed by Twig, by for statement.

Everything work's fine until, I put another variable into my section content in mySQL base.

I does it becouse I want to made child element for my section, which could be displayed only into her area.

Twig for loop:

    {% for section in sections %}
      {{ section.content }}
    {% endfor %}

Value of section.content in mySQL base:

Lorem ipsum {{ section.name }}

Result which I saw is plain text, without rendering by twig, so it looks like content in base.

Lorem ipsum {{ section.name }}

What could I do to print variable inside other variable in Twig engine?

Thanks.

AK994
  • 15
  • 1
  • 6
  • If I understand correctly You can use the twig function attribute to access a "dynamic" attribute of a variable: https://twig.symfony.com/doc/2.x/functions/attribute.html – Med Feb 20 '19 at 15:34
  • Possible duplicate of [Render content from string/database and generate links with twig](https://stackoverflow.com/questions/9803353/render-content-from-string-database-and-generate-links-with-twig) – DarkBee Feb 20 '19 at 15:59
  • @Med Problem existing when I trying to print any variable into another variable. Ex.: {{ header }} and content of header will be for ex.: Example plain tekst before ad link {{ adlink }} Variable cannot be embedded into another variable, its any way to fix it? – AK994 Feb 20 '19 at 18:49

0 Answers0