1

jQuery-ui datepicker を使用していますが、画像とパスに問題があります。これは私のcssをリンクする方法です:

    {% stylesheets  '@BackendBundle/Resources/public/css/bootstrap.min.css' 
                    '@BackendBundle/Resources/public/css/bootstrap-responsive.min.css' 
                    '@HotelBundle/Resources/public/css/ui-lightness/jquery-ui-1.8.20.custom.css' 
                    '@HotelBundle/Resources/public/css/encargado.css'
               output='css/encargado.css' %}
        <link href="{{ asset_url }}" rel="stylesheet" type="text/css" />
    {% endstylesheets %}
{% endblock %}

{% block javascripts %}
    {% javascripts  '@BackendBundle/Resources/public/js/jquery-1.7.2.min.js' 
                    '@BackendBundle/Resources/public/js/modernizr-2.5.3-respond-1.1.0.min.js' 
                    '@HotelBundle/Resources/public/js/jquery-ui-1.8.20.custom.min.js' 
                    output='js/backend.js' %}
        <script src="{{ asset_url }}" type="text/javascript"></script>
    {% endjavascripts %}

そこにcssファイルを保存します:

../src/Gitek/HotelBundle/Resources/public/css/ui-lightness/
 - jquery-ui-1.8.20.custom.css
 - images/ui-bg_diagonals-thick_18_b81900_40x40.png;ui-bg_diagonals-thick_20_666666_40x40.png ...

そこに私のjsファイル:

../src/Gitek/HotelBundle/Resources/public/js/jquery-ui-1.8.20.custom.min.css

その後、エラーなしで php app/console assetic:dump でアセットをダンプします

また、php app/console assets:install web --symlink を使用してアセットをインストールします

キャッシュをクリアします php app/console cache:clear

私はこれをすべて行い、日付ピッカーを表示して操作できますが、一部の写真が読み込まれません。Chrome コンソールにアクセスすると、次のエラーが表示されます。

Failed to load resource: the server responded with a status of 404 (Not Found) http://hotel.local/app_dev.php/css/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
Failed to load resource: the server responded with a status of 404 (Not Found) http://hotel.local/app_dev.php/css/images/ui-bg_gloss-wave_35_f6a828_500x100.png
Failed to load resource: the server responded with a status of 404 (Not Found) http://hotel.local/app_dev.php/css/images/ui-bg_glass_100_f6f6f6_1x400.png
Failed to load resource: the server responded with a status of 404 (Not Found) http://hotel.local/app_dev.php/css/images/ui-icons_ffffff_256x240.png
Failed to load resource: the server responded with a status of 404 (Not Found) http://hotel.local/app_dev.php/css/images/ui-bg_highlight-soft_75_ffe45c_1x100.png

おそらくcssファイル内のパスに問題があると思いますが、よくわかりません。

何か助けはありますか?

4

4 に答える 4

1

1) config.yml で cssrewrite フィルターを有効にします。

assetic:
    filters:
        cssrewrite: ~

2) 相対 URL と cssrewrite フィルターを使用して css ファイルを一覧表示します。

{% stylesheets '/bundles/backend/css/bootstrap.min.css' 
               '/bundles/backend/css/bootstrap-responsive.min.css' 
               '/bundles/hotel/css/ui-lightness/jquery-ui-1.8.20.custom.css' 
               '/bundles/hotel/css/encargado.css'
               output='css/encargado.css' filter='cssrewrite' %}
<link href="{{ asset_url }}" rel="stylesheet" type="text/css" />
{% endstylesheets %}

フィルターは、すべての CSS URL を適切に書き換える必要があります。

于 2012-08-02T21:07:57.207 に答える
0

cssrewrite filter + load images を使用して css をロードする必要があります。

{% block stylesheets %}
  {% stylesheets 'bundles/testbundle/css/jquery-ui/jquery-ui.css' filter='cssrewrite' %}
     <link rel="stylesheet" href="{{ asset_url }}" type="text/css" />
  {% endstylesheets %}
  {% image '@TestBundle/Resources/public/css/jquery-ui/images/*' %}{% endimage %}
{% endblock %}

アセットをインストールしてダンプするよりも。

于 2015-01-08T15:56:23.233 に答える