Answer the question
In order to leave comments, you need to log in
Where is the best place in Symfony to store data displayed on all pages of the application?
Such data includes, for example, a phone number and an address that will be displayed in the footer on each page of the site. It seems that creating a separate entity for this and storing it in the database is not a good idea. And how to do it optimally? Store it in twig configs? And is it possible to make a simple editor of this through a form, for example?
Answer the question
In order to leave comments, you need to log in
https://symfony.com/doc/master/templating/embeddin...
// src/ControllerIndexController::data
public function data()
{
$data = $this->getDoctrine()->getRepository(Data::class)->findOneBy([]);
return $this->render('data.html.twig', ['data' => $data]);
}
<!-- data.html.twig -->
{{ data }}
<!-- base.html.twig -->
{% block footer %}
<footer>
{{ render(controller('App\\Controller\\IndexController::data')) }}
</footer>
{% endblock %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question