Search code examples
phpsymfonyfosuserbundlesonata

Two templates showed


I'm using FOSUserBundle on my Symfony4 project, and I overrode all bundle templates, and place them on my templates folder. I have my base.html.twig file, is the main page template that contains initial HTML script for all stylesheets and javascript files. On the body I added the content block:

<body>
    {% block content %}{% endblock content %}
</body>

Then, on my login template, I extended the main template and added the fos_user_content block:

{% extends 'bundles/landing.html.twig' %}
{% block content %}
    {% block fos_user_content %}
{% endblock content %}

And for the moment everything is ok. The login form is displayed well. But when I log into this form, the system switched me to the Profile page. The problem, is that, the profile page template is showed and the login template too. Both the templates are used. On the profile template, I extended the main template too + added the same block content, except the fos_user_content block.


Solution

  • You missed an {% endblock fos_user_content %} tag

    {% extends 'bundles/landing.html.twig' %}
    {% block content %}
        {% block fos_user_content %}{% endblock fos_user_content %}
    {% endblock content %}