dongzan9069 2014-07-14 03:25
浏览 24
已采纳

覆盖默认的FOSUserBundle模板,没有效果

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?

  • 写回答

2条回答 默认 最新

  • dsfds4551 2014-07-14 06:20
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题