Overriding templates
In order to override a template that ships with a third-party bundle (such as SonataUserBundle
), we have to create a duplicate of it in the app/Resources
folder and modify it here.
To see how it works, let's start with the login page. At the moment, it looks ugly and empty and covered with some unnecessary elements.
Copy a few folders from sonata-project
to your app/Resources
folder as follows:
$ mkdir app/Resources/SonataUserBundle $ cp -r vendors/sonata-project/user-bundle/Resources/views/app/Resources/SonataUserBundle/
Now edit Security/base_login.html.twig
as follows:
{# app/Resources/SonataUserBundle/views/Security/base_login.html.twig #} {% extends '::mavaBase.html.twig' %} {% block mavaBody %} {% block fos_user_content ...
Get Mastering Symfony now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.