How would I go about executing a database query on every page within a Symfony2 bundle?
I'm attempting to create a who's online functionality but this requires a query to be executed globally.
Thanks! :)
You can render a sub-template, for example (in a project of mine) in my layout.html.twig I have this:
{% render "EUPaNdataBundle:Home:listAllInstitutes" %}
This will render a list of all institutes in a drop down menu in the top navigation bar.
listAllInstitutes is an action in the Home controller which gets a list of institutes from the DB and then returns the listAllInstitutes.html.twig template
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With