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 %} {# rest of the template #} {% endblock %} {% endblock %}
Here, you can see the benefit of saving blocks in separate files. As it is extended from the mava_base
template, no menu will be shown, which is what we want. Visit the login...