可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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:
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.
Unzip it
Rename the unzipped folder to 'bootstrap'
check that you have the folder structure ernie mentions below.
upload your new bootstrap folder to protected/extensions
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.