2016-03-11 61 views
-1

首先,我告訴我我其實創建如何創建包括yii2後端定製主題

1)我的主題文件夾yii2 \後端\網絡\主題\基本包含我所有的CSS,JS文件爲主題

2)我配置我的主題yii2 \後端\ CONFIG \ main.php如下:

'components' => [ 
    'view' => [ 
     'theme' => [ 
      'basePath' => '@app/themes/basic', 
      'baseUrl' => '@web/themes/basic', 
      'pathMap' => [ 
       '@app/views' => '@app/themes/basic', 
      ], 
     ] 
    ] 
], 

3)包括我在yii2 \後端\資產的所有CSS和JS文件\ AppAsset .PHP

 public $basePath = '@webroot'; 
public $baseUrl = '@web'; 
public $css = [ 
    //'css/site.css', 
    'plugins/pace/pace-theme-flash.css', 
    //'plugins/boostrapv3/css/bootstrap.min.css', 
    //'plugins/boostrapv3/css/bootstrap-theme.min.css', 
    'plugins/font-awesome/css/font-awesome.css', 
    'css/animate.min.css', 
    'plugins/jquery-scrollbar/jquery.scrollbar.css', 
    'css/style.css', 
    'css/responsive.css', 
    'css/custom-icon-set.css', 
]; 
public $js = [ 
    //'plugins/jquery-1.8.3.min.js', 
    //'plugins/jquery-ui/jquery-ui-1.10.1.custom.min.js', 
    //'plugins/boostrapv3/js/bootstrap.min.js', 
    'plugins/breakpoints.js', 
    'plugins/jquery-unveil/jquery.unveil.min.js', 
    'plugins/jquery-scrollbar/jquery.scrollbar.min.js', 
    'plugins/jquery-numberAnimate/jquery.animateNumbers.js', 
]; 
public $depends = [ 
    'yii\web\YiiAsset', 
    'yii\bootstrap\BootstrapAsset', 
]; 

而我的問題是,我的CSS和JS沒有被發現它給出了404錯誤 我的文件位置就像http://192.168.1.1:1010/backend/web/plugins/pace/pace-theme-flash.css。但我的實際文件鏈接http://192.168.1.1:1010/backend/web/themes/basic/plugins/pace/pace-theme-flash.css

爲什麼它不工作。誰能幫我這個....

回答

0

如果文件的位置是像你說的

http://192.168.1.1:1010/backend/web/plugins/pace/pace-theme-flash.css 

,而不是

http://192.168.1.1:1010/backend/web/themes/basic/plugins/pace/pace-theme-flash.css 

的你basPath和基準網址應該是

'components' => [ 
    'view' => [ 
    'theme' => [ 
     'basePath' => '@app', 
     'baseUrl' => '@web', 
     'pathMap' => [ 
      '@app/views' => '@app/themes/basic', 
     ], 
    ] 
    ] 
], 

,並最終檢查應用程序/視圖..

或在您的yii2 \後端\資產\ AppAsset.php

 public $basePath = '@webroot/themes/basic'; 
     public $baseUrl = '@web/themes/basic'; 
+0

感謝scaisEdge您的回覆。它不起作用。據我的CSS和JS文件都顯示我有更新的答案不正確的路徑只有 – Sivabalan

+0

.. – scaisEdge