yii Yii:app()->user->name 如果不设置默认是guest,怎么自定义这个guest

WBOY
Release: 2016-06-13 12:22:20
Original
1029 people have browsed it

yii Yii::app()->user->name 如果不设置默认是guest,如何自定义这个guest?
前提默认全局语言以设置为中文
以框架安装完为例:
例如在登陆后user->name;?>会显示默认的admin或者demo,
但如果没有登陆user->name;?>会显示guest,如何设置这个guest?
求指教?
------解决思路----------------------

<br />class CWebUser extends CApplicationComponent implements IWebUser<br />{<br />        public $guestName='Guest';<br />        ...<br />
Copy after login

应该在protected/components中有个WebUser继承了,自己改咯
我不知道用的是不是原生Yii,给你参考下
------解决思路----------------------
你觉得直接改不是很好的话,你就自己创建一个类,继承CWebUser, 配置文件里面制定 Yii::app()->user 为你自己创建的类。然后你修改你自己创建的这个类就可以了。
------解决思路----------------------
不用定义类,你直接在配置文件时设置user的时候,指定属性$guestName=XX就行了,所有属性都可以在配置文件中重新定义。程序会按你的配置来实例化

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!