我有一个像
这样的问题Yii::app()->getModule('user') is not returning the right value view/layout/main.php
但我有一个不同的情况,我不能树脂化它,它是使用右扩展。 在主配置
'application.models.*',
'application.components.*',
'application.modules.rights.*',
'application.modules.rights.components.*',
'rights'=>array(
'superuserName'=>'Admin', // Name of the role with super user privileges.
'authenticatedName'=>'Authenticated', // Name of the authenticated user role.
'userIdColumn'=>'id', // Name of the user id column in the database.
'userNameColumn'=>'username', // Name of the user name column in the database.
'enableBizRule'=>true, // Whether to enable authorization item business rules.
'enableBizRuleData'=>false, // Whether to enable data for business rules.
'displayDescription'=>true, // Whether to use item description instead of name.
'flashSuccessKey'=>'RightsSuccess', // Key to use for setting success flash messages.
'flashErrorKey'=>'RightsError', // Key to use for setting error flash messages.
'install'=>false, // Whether to enable installer.
'debug'=>false, // Whether to enable debug mode.
),
然后我需要更新此应用程序以使用用户扩展.. 我正在尝试,结果是:
Trying to get property of non-object
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),
&LT;已更新&gt;
现在我得到了不同的错误:
Trying to get property of non-object
public function tableName()
{
return Yii::app()->getModule('user')->tableUsers;
}
位于\ protected \ modules \ user \ models \ User.php(41)
我在config main中的代码我更新如下:
'modules'=>array(
'user'=>array(
'tableUsers' => 'tbl_users',
'tableProfiles' => 'tbl_profiles',
'tableProfileFields' => 'tbl_profiles_fields',
任何想法我的错? *索里,如果我的语法不好。
答案 0 :(得分:0)
SOLVED
在config main中
'rights'=>array(
'superuserName'=>'Admin', // Name of the role with super user privileges.
'authenticatedName'=>'Authenticated', // Name of the authenticated user role.
'userIdColumn'=>'id', // Name of the user id column in the database.
'userNameColumn'=>'username', // Name of the user name column in the database.
'enableBizRule'=>true, // Whether to enable authorization item business rules.
'enableBizRuleData'=>false, // Whether to enable data for business rules.
'displayDescription'=>true, // Whether to use item description instead of name.
'flashSuccessKey'=>'RightsSuccess', // Key to use for setting success flash messages.
'flashErrorKey'=>'RightsError', // Key to use for setting error flash messages.
//'baseUrl'=>'/rights', // Base URL for Rights. Change if module is nested.
//'layout'=>'rights.views.layouts.main', // Layout to use for displaying Rights.
//'appLayout'=>'application.views.layouts.main', // Application layout.
//'cssFile'=>'rights.css', // Style sheet file to use for Rights.
'install'=>false, // Whether to enable installer.
'debug'=>false, // Whether to enable debug mode.
),
'user'=>array(
'hash' => 'md5',
'tableUsers' => 'tbl_users',
'tableProfiles' => 'tbl_profiles',
'tableProfileFields' => 'tbl_profiles_fields',
并且不要更改模块中的任何内容.. 这很有效,就像魔法一样.. 洛尔