A
A
Alexander2020-07-11 14:36:28
symfony
Alexander, 2020-07-11 14:36:28

How to correctly pass information to the twig template header, footer?

How can I normally put information in the header and footer of the site
In the base template, I include header, footer
But I need to put some information there, for example:

  • menu items
  • contacts
  • ....

In the symphony manuals and the demo, this issue is easily solved :) - the links are just hardcore wired into the base template
. I can't find an example of how to do it right.

There is an option to Render the controller in the template, but it’s kind of strange, although there is such a thing in the

manual although global variables are evil, but here it will only work on read
twig:
    globals:
        menu: '@App\Services\Menu'


I'm at a crossroads, please tell me if there are any other methods

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2020-07-11
@alexmixaylov

for example https://symfony.com/doc/current/templating/twig_ex...
make a function to inject the necessary services drag info and display in the template

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question