How do I include stylesheets with symfony properly?

元气小坏坏 提交于 2019-12-13 19:21:57

问题


I have a simple Template (layout.php) and I use Propel as ORM.

When i include sylesheets (into of layout.php) with the function: include_stylesheets() I became 2 css:

/sfPropelORMPlugin/css/global.css

/sfPropelORMPlugin/css/default.css

why?

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

I configure no stylesheets but I see Propel css in my Head Tag!

my generator.yml :

generator:
 class: sfPropelGenerator
 param:

 ##CONFIG##

config:
  actions: ~
  fields:  ~
  list:    ~
  filter:  ~
  form:    ~
  edit:    ~
  new:     ~

Is this a bug? or just a misconfiguration?


回答1:


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; ?>

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

Or removed them:

generator:
  class: sfPropelGenerator
  param:
    css:          false

edit:

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


来源:https://stackoverflow.com/questions/11115222/how-do-i-include-stylesheets-with-symfony-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!