Twitter Bootstrap in Yii

余生颓废 提交于 2019-12-05 02:51:12

问题


I'm pretty new to Yii as well as Twitter Bootstrap, I am trying to use the files provided by bootstrap. I have unzipped the downloaded folder in extensions directory of protected folder in Yii, and followed this http://www.cniska.net/yii-bootstrap/setup.html#setup The code in my main.php looks like:

'preload'=>array('log','bootstrap'),
'import'=>array(
...
'application.extensions.bootstrap.widgets.*',
),
'modules'=>array(
     'generatorPaths'=>array(
        'bootstrap.gii',
      ),

),
'components' => array(
'bootstrap'=>array(
        'class'=>'ext.bootstrap.components.Bootstrap',
),
),

I get this error
Alias "ext.bootstrap.components.Bootstrap" is invalid. Make sure it points to an existing PHP file.

Q2. Is there any better way other than just copy paste the whole bootstrap css file in Yii's css?

Q3. Do I have to download anything extra to use the widgets provided by bootstrap twitter like, $this->widget('ext.cssmenu.CssMenu',array(...); where should the downloaded files be located?


回答1:


I think you might be downloading the wrong files! You don't download bootstrap from the twitter github page - instead you download the yii extension, which has all the boostrap files bundled in.

Here's a step by step guide:

  1. Download this file - http://www.yiiframework.com/extension/bootstrap/files/yii-bootstrap-0.9.12.r211.zip - I'd use this rather than the alpha v 1.0 for stability.

  2. Unzip it

  3. Rename the unzipped folder to 'bootstrap'

  4. check that you have the folder structure ernie mentions below.

  5. upload your new bootstrap folder to protected/extensions

  6. make the changes to your protected/config/main.php given here - http://www.cniska.net/yii-bootstrap/setup.html#setup - but it looks like you've already done this.

Everything should now be working.




回答2:


If You were just downloaded Yii v1.1.12 unzip bootatrap files to protected/components/bootstrap/ as like below:

protected/components/bootstrap/widgets/ protected/components/bootstrap/components/ protected/components/bootstrap/...etc..

after that in protected/config/main.php change

ext.bootstrap.components.Bootstrap

to

application.components.bootstrap.components.Bootstrap




回答3:


A1) Verify that you unzipped the contents of the zip to /protected/extensions/bootstrap. In that directory, you should have:

assets
components
gii
lib
widgets
LICENSE.txt

If you've got yii-bootstrap-version_desginator, then you didn't extract the contents as expected.

Note that in general, you're seeing paths in your config file, e.g.: ext.bootstrap.components.Bootstrap corresponds to extensions/bootstrap/components/Bootstrap.php. The error message is telling you that it can't find that file.

A2) While I haven't used this extension, I'm guessing you do not need to copy the CSS into the Yii CSS, and the extension will load it as necessary.

A3) I don't know about this one




回答4:


I had the same problem. I solved it by change rights on bootstrap folder to "755"




回答5:


A1. You need to make sure you've copied across the Bootstrap.php file to your protected/extensions/bootstrap/components folder.

A2. You don't need to worry about that, if uploaded the files to your extensions directory then the Bootstrap css files will appear in your layouts by magic

A3. Nope - the Bootstrap extension gives you everything you need to use both the basic Bootstrap CSS and the jQuery plugins.

Hope this helps.




回答6:


Download the yii-bootstrap zip file from the link provided by DaveR (www.yiiframework.com/extension/bootstrap/files/yii-bootstrap-0.9.12.r211.zip), because it is an older, stable version and use his instructions to setup the folders and whatnot.

Use this address http://pastebin.com/xVSPNgJi to setup your main.php config file in 'webapp'/protected/config. It is a little more explicit than the yii-bootstrap site, and if you're not too familiar with yii, this should help clarify.

Then, if you want to copy and paste the buttons and navbars and whatever from the docs at this address, http://cniska.net/yii-bootstrap/index.html then you will have to download the latest version of yii-bootstrap and copy the contents of THAT widgets folder into your protected/extensions/bootstrap/widgets folder.

Setting up the latest version didn't work for me either, pretty sure yii isn't recognizing it properly, but the older version did work fine.



来源:https://stackoverflow.com/questions/11866179/twitter-bootstrap-in-yii

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!