我如何正确地包含带有 symfony 的样式表? [英] How do I include stylesheets with symfony properly?
问题描述
我有一个简单的模板 (layout.php),我使用 Propel 作为 ORM.
I have a simple Template (layout.php) and I use Propel as ORM.
当我在函数中包含 sylesheets(到 layout.php 中)时:include_stylesheets()
我变成了 2 个 css:
When i include sylesheets (into of layout.php) with the function: include_stylesheets()
I became 2 css:
/sfPropelORMPlugin/css/global.css
/sfPropelORMPlugin/css/global.css
/sfPropelORMPlugin/css/default.css
/sfPropelORMPlugin/css/default.css
为什么?
当我查看我的 view.yml 实际上我只有这个:
when I look into my view.yml actually I just have this:
default:
http_metas:
content-type: text/html
stylesheets:
has_layout: true
layout: layout
我没有配置样式表,但我在我的 Head 标签中看到了 Propel css!
I configure no stylesheets but I see Propel css in my Head Tag!
我的generator.yml:
generator:
class: sfPropelGenerator
param:
##CONFIG##
config:
actions: ~
fields: ~
list: ~
filter: ~
form: ~
edit: ~
new: ~
这是一个错误吗?还是只是配置错误?
Is this a bug? or just a misconfiguration?
推荐答案
这主要是因为使用管理模板时会自动加载(查看此文件):
This mainly because there are automatically loaded when you use a the admin template (see this file):
<?php if (isset($this->params['css']) && ($this->params['css'] !== false)): ?>
[?php use_stylesheet('<?php echo $this->params['css'] ?>', 'first') ?]
<?php elseif(!isset($this->params['css'])): ?>
[?php use_stylesheet('<?php echo sfConfig::get('sf_admin_module_web_dir').'/css/global.css' ?>', 'first') ?]
[?php use_stylesheet('<?php echo sfConfig::get('sf_admin_module_web_dir').'/css/default.css' ?>', 'first') ?]
<?php endif; ?>
这意味着您可以在 generator.yml
中定义自己的 css(并且不会加载默认的),例如:
This means you can define your own css in the generator.yml
(and it won't load the default ones), like :
generator:
class: sfPropelGenerator
param:
css: /css/my_css.css
或删除它们:
generator:
class: sfPropelGenerator
param:
css: false
最后你可以从 view.yml
中删除它们:
And finally you can remove them from the view.yml
:
default:
http_metas:
content-type: text/html
stylesheets:
- -/sfPropelORMPlugin/css/global.css
- -/sfPropelORMPlugin/css/default.css
has_layout: true
layout: layout
这篇关于我如何正确地包含带有 symfony 的样式表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!