国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 尖扎县| 潞西市| 铜陵市| 体育| 兰坪| 曲周县| 平武县| 江西省| 廊坊市| 法库县| 辽阳市| 扎赉特旗| 淮阳县| 江永县| 阳江市| 夏邑县| 普陀区| 乌鲁木齐市| 横山县| 潮安县| 北辰区| 曲松县| 邯郸市| 洞头县| 蓝田县| 大洼县| 兴城市| 西华县| 湄潭县| 信丰县| 凌海市| 北安市| 沈阳市| 新竹市| 临洮县| 林州市| 崇左市| 新和县| 南京市| 南京市| 海兴县|