Yii::app()->getModule('user') is not returning the right value view/layout/main.php

戏子无情 提交于 2020-01-06 08:00:51

问题


Yii::app()->getModule('user') is not returning the right value in view/layouts/main.php

I am using Yii-User YII-User Extension to manage the User related features. When I Yii::app()->getModule('user')->loginUrl,

I get

Trying to get property of non-object

at

array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),

Pls tell me whats going wrong, is it a known issue or something like that.

Here is the config/main.php

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

),
   'modules' => array(

         'user'=>array(

                # enable debuging 
                'debug' => true,

                # 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'),

                # Adding Table refrences 
                'tableUsers' => 'tbl_users',
                'tableProfiles' => 'tbl_profiles',
                'tableProfileFields' => 'tbl_profiles_fields',
                ),
        ),

回答1:


I was able to solve this exact issue by removing everything I had done to install the extension orginally and then getting the latest version from the github page on the yii-user extension page.

I then installed the db schemea using no tbl_ prefix while following this guide. http://www.benjaminlhaas.com/blog/installing-yii-users-and-rights-5-steps

However, I had to install the db schema for rights manually to get this all to work.

If you have any other questions feel free to ask!



来源:https://stackoverflow.com/questions/11371004/yiiapp-getmoduleuser-is-not-returning-the-right-value-view-layout-main

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!