【问题标题】:FOSUserBundle, How include own stylesheet files?FOSUserBundle,如何包含自己的样式表文件?
【发布时间】:2013-06-10 22:12:05
【问题描述】:

我想更改 FOSUserBundle 中登录表单的默认样式。在我的包中,在views/layout.html.twig 中我写了这个:

<!DOCTYPE html>
<html>
<head>
{% block stylesheets %}
    <link href="{{ asset('/bundles/user/css/demo.css') }}" type="text/css" rel="stylesheet" />
{% endblock %}
</head>
<body>
{% block body %}
{{ block('fos_user_content') }}
{% endblock %}
</body>
</html>

然后在终端我把这个:

app/console assets:install web --symlink

之后我得到 web/bundles/user/css/demo.css

但清除缓存后 FireBug 不显示任何包含的 css 文件...为什么?

【问题讨论】:

  • 样式表未显示在源代码中或未加载?

标签: symfony fosuserbundle


【解决方案1】:

只需在以下位置创建模板,即可通过包继承覆盖 FOSUserBundle::layout.html.twig

app/Resources/FOSUserBundle/views/layout.html.twig

此模板必须包含 fos_user_content 块。

FOSUserBundle 的原始基础模板可以在here 找到。

进一步阅读食谱文章Overriding Bundle Templates

【讨论】:

  • 谢谢。你是我个人的 Symfony 老师 :)。你又帮我了。
  • 呵呵很高兴我能再次提供帮助:D 快乐编码!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-10
  • 1970-01-01
  • 2011-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多