没有加载Twitter Bootstrap的Yii框架

时间:2013-03-12 15:42:52

标签: php twitter-bootstrap yii yii-extensions

我是Yii的新手,想要实现Twitter Bootstrap扩展,我已经关注了 cniska但显然我做错了。

当我在浏览器中使用扩展程序代码加载页面时,图片/效果无法加载。

在我的html页面中,我找到了这个简单的切换按钮here

  <?php $this->widget('bootstrap.widgets.TbButton', array(
      'buttonType'=>'button',
      'type'=>'primary',
      'label'=>'Toggle me',
      'toggle'=>true,
  )); ?>

这样的结果就好像我刚刚完成了一个没有应用类的简单HTML按钮,一个'裸'的按钮,所以请说。

我的config / main.php:

Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');

return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Test App',

// preloading 'log' component
'preload'=>array('log'),

// autoloading model and component classes
'import'=>array(
    'application.models.*',
    'application.components.*',
),

'modules'=>array(
    'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'<password>',
        'ipFilters'=>array('127.0.0.1','::1'),
    ),
),

'components'=>array(
    'user'=>array(
      'allowAutoLogin'=>true,
  ),
  'bootstrap'=>array(
    'class'=>'bootstrap.components.Bootstrap',
   ),

  'theme'=>'bootstrap', -// requires you to copy the theme under your themes directory
    'modules'=>array(
        'gii'=>array(
            'generatorPaths'=>array(
                'bootstrap.gii',
            ),
        ),
    ),

    'db'=>array(
        'connectionString' => 'mysql:host=localhost;dbname=<bdname>',
        'emulatePrepare' => true,
        'username' => '<bd username>',
        'password' => '<bd password>',
        'charset' => 'utf8',
    ),

    'errorHandler'=>array(
        'errorAction'=>'site/error',
    ),
    'log'=>array(
        'class'=>'CLogRouter',
        'routes'=>array(
            array(
                'class'=>'CFileLogRoute',
                'levels'=>'error, warning',
            ),

        ),
    ),
),

// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
    // this is used in contact page
    'adminEmail'=>'webmaster@example.com',
),
);

我也相信我有最新版本,因为我本周下载了Yii的框架以及扩展。 有什么提示吗?

提前致谢

2 个答案:

答案 0 :(得分:3)

你需要注册css和js文件, 在主要布局中添加此行

Yii::app()->bootstrap->register();

答案 1 :(得分:0)

您必须更新main.config,将其更改为在preload部分加载引导程序,如下所示:

'preload'=>array('log', 'bootstrap'),

或者调用@neophile在您需要的每种情况下编写的代码。

使用可能会查看official guideline初始设置(Initialization options部分)