In my layout.html.twig I have a navigation bar with some links. I want the links to be populated from a database.
For example, in the navigation bar I have a drop down of ‘Recent Products’. How can I populate the dropdown in the main layout.html.twig from a database? (of course it’ll be cached in the future)
Do I need to create a filter?
Any help would be great. Thanks
Note: In Symfony 1.4 I would have used a component. Does this exist in Symfony 2?
The answer is here: http://symfony.com/doc/2.0/book/templating.html#embedding-controllers
I needed to create a sub-controller and then embed the sub-controller view into the main twig layout.