3

我想在我的 Symfony2 项目中支持基本的主题,所以我想为每个主题分离静态文件(css、js、img)。

我试图添加

assetic:
    read_from:  %kernel.root_dir%/../web/themes/mytheme

但这没有效果,我的 {{asset('css/style.css') }} 仍然将 realtic 引用到 %kernel.root_dir%/../web,而不是 %kernel.root_dir%/../web/themes /mytheme。

任何的想法?

4

1 回答 1

5

用配置修复:

assetic:
    debug:          %kernel.debug%
    use_controller: false
    read_from: %kernel.root_dir%/../web/bundles/mybundle/themes/%my_theme%
    write_to: %kernel.root_dir%/../web
    filters:
        yui_css:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
        yui_js:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"

在布局中我有:

    {% stylesheets 'css/*' filter='?yui_css' %}
    <link rel="stylesheet" type="text/css" media="all" href="{{ asset_url }}" />
    {% endstylesheets %}
于 2011-05-24T14:41:34.030 回答