2

我有一个使用 yii 框架的网站。首先,在我启动并运行网站后,我想安装引导程序(yii-bootstrap-1.2.0.r300.zip)。然而,这并不顺利。

我收到以下错误“未定义属性“CWebUser.bootstrap”。”

Bootstrap 扩展被放置为 /site/protected/extensions/bootstrap

我的主要配置文件看起来像这样

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'PeerPilot',
'theme'=>'newssourcefinal', // biskit is sub directory name under theme directory

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

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

'modules'=>array(
    'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'helloworld',
        'generatorPaths'=>array(
            'bootstrap.gii',),
        // If removed, Gii defaults to localhost only. Edit carefully to taste.
        // 'ipFilters'=>array('127.0.0.1','::1'),
    ),
),

// application components
'components'=>array(
    'user'=>array(
        // enable cookie-based authentication
        'allowAutoLogin'=>true,
        'bootstrap'=>array(
            'class'=>'ext.bootstrap.components.Bootstrap', // assuming you extracted bootstrap under extensions
        ),
    ),
    // 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',
    ),

    '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',
            ),
            */
        ),
    ),
),

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

1 回答 1

3

替换您的 config/main.php 如下

'components'=>array(
//..........
'user'=>array(
      'allowAutoLogin'=>true,
),    

'bootstrap' => array(
    'class'=>'ext.bootstrap.components.Bootstrap'
     )
)
于 2012-11-27T14:53:19.767 回答