檢查這個擴展出
Yii admin module
打開AdminModule.php,存在用於配置您的管理模塊的位置。我只是張貼了部分你需要什麼
public function getAssetsUrl()
{
if (!isset($this->assetsUrl))
{
$assetsPath = Yii::getPathOfAlias('admin.assets');
$this->assetsUrl = Yii::app()->assetManager->publish($assetsPath, false, -1, $this->forceCopyAssets);
}
return $this->assetsUrl;
}
protected function registerCoreCss()
{
Yii::app()->clientScript->registerCssFile($this->getAssetsUrl() . '/css/admin.css');
}
protected function registerScript(){
$js_arr = array('jquery.min.js', 'jqueryui.js'); //put what js file name that you need to import from admin assets folder
foreach($js_arr as $filename){
Yii::app()->getClientScript()->->registerScriptFile($this->getAssetsUrl().'/js/'.$filename, CClientScript::POS_END);
}
}
然後在init()
public function init(){
//set import ...
// configure module ...
// configure component ....
$this->registerCoreCss();
$this->registerScript();
}
還是謝謝Telvin Nguyen!我明白了! – Chain
我解決了myq問題閱讀此線程:http://stackoverflow.com/questions/12969358/how-do-i-add-scripts-and-stylesheets-inside-yii-module – Chain
可能的重複[包括CSS,javascript在Yii框架中的文件](http://stackoverflow.com/questions/1998449/include-css-javascript-file-in-yii-framework) – Manquer