国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > 建站經(jīng)驗 > 正文

Yii中單獨為module加載Bootstrap或其他組件的4種方法

2024-08-30 19:06:37
字體:
供稿:網(wǎng)友

Bootstrap中包含了豐富的Web組件,根據(jù)這些組件,可以快速的搭建一個漂亮、功能完備的網(wǎng)站,但是有時候我們網(wǎng)站前臺并不需要Bootstrap,只要管理后臺使用Bootstrap,那么該如何單獨為一個module加載Bootstrap呢?

這里有4種方法來實現(xiàn)這個:

1.在應(yīng)用的配置文件protected/config/main.php中添加如下內(nèi)容:

  1. 'modules'=>array
  2.         'admin'=>array
  3.             'preload'=>array('<span class='wp_keywordlink_affiliate'><a href="http://lxy.me/tag/bootstrap" title="查看 bootstrap 中的全部文章" target="_blank">bootstrap</a></span>'), 
  4.             'components'=>array
  5.                 '<span class='wp_keywordlink_affiliate'><a href="http://lxy.me/tag/bootstrap" title="查看 bootstrap 中的全部文章" target="_blank">bootstrap</a></span>'=>array
  6.                     'class'=>'ext.bootstrap.components.Bootstrap' 
  7.             ) 
  8.         ), 
  9.     // ...其他模塊... 
  10.     )  

2.在模塊初始化時加載,代碼如下:

  1. public function init() 
  2.     // import the module-level models and components 
  3.     $this->setImport(array
  4.         'admin.models.*'
  5.         'admin.components.*'
  6.         // 'ext.bootstrap.components.Bootstrap', // this will go to app config for components 
  7.     )); 
  8.     Yii::app()->getComponent('bootstrap');// this does the loading 

3.模塊初始化加載的另一種方法:

  1. public function init() 
  2.     { 
  3.         // import the module-level models and components 
  4.         $this->setImport(array
  5.             'admin.models.*'
  6.             'admin.components.*'
  7.         )); 
  8.         $this->configure(array
  9.                 'components'=>array
  10.                     'bootstrap'=>array
  11.                         'class'=>'ext.bootstrap.components.Bootstrap' 
  12.                     ) 
  13.                 ) 
  14.         )); 
  15.         $this->getComponent('bootstrap'); 
  16.     } 

4.模塊加載時的另一種方法,代碼如下:

  1. public function init() 
  2.     // import the module-level models and components 
  3.     $this->setImport(array
  4.         'admin.models.*'
  5.         'admin.components.*'
  6.     )); 
  7.     $this->configure(array
  8.             'preload'=>array('bootstrap'), 
  9.             'components'=>array
  10.                 'bootstrap'=>array
  11.                     'class'=>'ext.bootstrap.components.Bootstrap' 
  12.                 ) 
  13.             ) 
  14.     )); 
  15.     $this->preloadComponents(); 
  16. }

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 封丘县| 荔波县| 肇东市| 衡阳市| 白玉县| 肥城市| 清河县| 铜陵市| 改则县| 新密市| 西丰县| 栾川县| 泰顺县| 温泉县| 江口县| 榆树市| 曲靖市| 新竹县| 浦北县| 旬阳县| 垦利县| 共和县| 罗平县| 永靖县| 敖汉旗| 金溪县| 图片| 黄龙县| 阿荣旗| 四子王旗| 白沙| 临潭县| 十堰市| 南昌市| 贡山| 韶山市| 淮阳县| 昔阳县| 宝丰县| 扶余县| 同江市|