覆盖默认的FOSUserBundle模板,无效 [英] Overriding default FOSUserBundle template, no effect

查看:80
本文介绍了覆盖默认的FOSUserBundle模板,无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我知道还有其他类似的问题.我检查了每个,但我没有弄错我在做什么.

Yep, I know there are other questions like these. I checked each one, but I'm not getting what I'm doing wrong.

我自己的模板位于:

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>

然后,按照文档说明,我创建了此结构以覆盖FOSUserBundle模板:

Then, following the documentation I have created this structure to override FOSUserBundle template:

src/Grit/GritWsBundle/Resources/FOSUserBundle/views/layout.html.twig

在此文件中,我正在扩展layoutBase.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?

推荐答案

您将模板放置在错误的位置.如文档所述,您需要放置<app/Resources/FOSUserBundle/views/layout.html.twig处的c0>(不在捆绑包内).

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).

如果要覆盖包中的模板,则需要覆盖FOSUserBundle.您可以在上面的链接 Symfony官方文档.

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.

这篇关于覆盖默认的FOSUserBundle模板,无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆