在yii上设置bootstrap

时间:2013-03-11 03:35:13

标签: twitter-bootstrap yii

我安装了Yii-Bootstrap并将其保存在protected / extensions文件夹中。之后我提取zip文件并将其命名为bootstrap。作为http://www.cniska.net/yii-bootstrap/setup.html的文档。

我像这样更改文件config / main.php。但是我无法得到结果。如果我做错了,请在这里建议我如何在yii上使用bootstrap。

<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/extensions/bootstrap');
return array(
  'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
  'name'=>'Tantra Songs',
    'theme'=>'bootstrap', // requires you to copy the theme under your themes directory

  // preloading 'log' component
  'preload'=>array('log','application.ext.bootstrap.*'),

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

  'modules'=>array(
    // uncomment the following to enable the Gii tool
    'gii'=>array(
      'generatorPaths'=>array(
                'bootstrap.gii',
            ),
    ),
    'user'=>array(
            # encrypting method (php hash function)
            'hash' => 'md5',

            # send activation email
            'sendActivationMail' => true,

            # allow access for non-activated users
            'loginNotActiv' => false,

            # activate user on registration (only sendActivationMail = false)
            'activeAfterRegister' => false,

            # automatically login from registration
            'autoLogin' => true,

            # registration path
            'registrationUrl' => array('/user/registration'),

            # recovery password path
            'recoveryUrl' => array('/user/recovery'),

            # login form path
            'loginUrl' => array('/user/login'),

            # page after login
            'returnUrl' => array('/user/profile'),

            # page after logout
            'returnLogoutUrl' => array('/user/login'),
        ),
  ),

  // application components
  'components'=>array(
    'user'=>array(
      // enable cookie-based authentication
      'allowAutoLogin'=>true,
    ),
    'bootstrap'=>array(
            'class'=>'bootstrap.components.Bootstrap',
        ),
    // uncomment the following to enable URLs in path-format
    'urlManager'=>array(
      'urlFormat'=>'path',
      'rules'=>array(
        '<controller:\w+>/<id:\d+>'=>'<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
      ),
    ),
    /*
    'db'=>array(
      'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
    ),*/
    // uncomment the following to use a MySQL database
    'db'=>array(
      'connectionString' => 'mysql:host=localhost;dbname=nt_songs',
      'emulatePrepare' => true,
      'username' => 'root',
      'password' => 'root',
      'charset' => 'utf8',
      'tablePrefix' => 'nt_',
    ),
    'errorHandler'=>array(
      // use 'site/error' action to display errors
      'errorAction'=>'site/error',
    ),
    'log'=>array(
      'class'=>'CLogRouter',
      'routes'=>array(
        array(
          'class'=>'CFileLogRoute',
          'levels'=>'error, warning',
        ),
        // uncomment the following to show log messages on web pages
        /*
        array(
          'class'=>'CWebLogRoute',
        ),
        */
      ),
    ),
  ),

);

1 个答案:

答案 0 :(得分:0)

我认为你设定的路径有点不正确。试试这个;

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