1

I'm new to Yii and wanted to implement the Twitter Bootstrap extension, I have followed cniska but apparently I'm doing something wrong.

When I load the page in the browser with extension code, the images/effects don't load.

In my html page I got this simple toggle button found here.

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

The result with this is as if I have just done a simple HTML button with no classes applied to it, a 'bare' sytle button, so do speak.

My 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',
),
);

I also believe I have the latest versions as I downloaded Yii's framework this week as well as the extension. Any tips?

Thanks in advance

4

2 回答 2

3

您需要注册 css 和 js 文件,在主布局中添加这一行

Yii::app()->bootstrap->register();
于 2013-03-12T19:19:43.173 回答
0

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

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

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

使用可以查看官方初始设置指南(Initialization options部分)

于 2017-07-17T13:27:22.730 回答