问题
Yep, I know there are other questions like these. I checked each one, but I'm not getting what I'm doing wrong.
My own template is located at:
src/Grit/GritWsBundle/Resources/views/layoutBase.html.twig
Which contains (hidden unnecessary markups):
<!DOCTYPE html>
<html>
<head></head>
<body>
<div class="container">
{% block content %}
{% endblock %}
</div>
</body>
</html>
Then, following the documentation I have created this structure to override FOSUserBundle template:
src/Grit/GritWsBundle/Resources/FOSUserBundle/views/layout.html.twig
In this file I'm extending the layoutBase.html.twig:
{% extends 'GritGritWsBundle::layoutBase.html.twig' %}
{% block content %}
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="login-panel panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Please Sign In</h3>
</div>
<div class="panel-body">
{% block fos_user_content %}
{% endblock %}
</div>
</div>
</div>
</div>
{% endblock %}
I have already cleared the cache, installed and 'dump' assets.
Somehow it's not working, doesn't take effect. Can someone help me?
回答1:
You placed your template in the wrong place. As stated in the documentation you need to place your layout.html.twig
at the app/Resources/FOSUserBundle/views/layout.html.twig
(not inside your bundle).
If you want to override template in your bundle you need to override FOSUserBundle by yours. You can find information in the link above and on the Symfony official documentation.
回答2:
To override the template, your file path and name needs to mirror the path and name of the template you are overriding. Rename from templateBase
to template
.
Be sure to clear the symfony cache afterwards to see your result
来源:https://stackoverflow.com/questions/24729115/overriding-default-fosuserbundle-template-no-effect