在Yii中获取当前控制器和操作ID
I want to force all users to log in before accessing pages of my site. I have followed Larry Ullman's tutorial Forcing Login for All Pages in Yii.
我想强制所有用户在访问我的网站页面之前登录。我已经关注了Larry Ullman的教程强制登录Yii中的所有页面。
According to the tutorial you can make an exception for some pages to avoid redirecting to the log in page. In order to check the current controller it has checked $_GET
value. My problem is that I have used urlManager
to rewrite the URL and $_GET
gives me a null value. Is there any method I can use to get the current controller and action in the score of my class?
根据教程,您可以为某些页面设置例外,以避免重定向到登录页面。为了检查当前控制器,它检查了$ _GET值。我的问题是我使用urlManager重写URL,$ _GET给我一个空值。有没有什么方法可以用来获得当前控制器和我班级成绩的动作?
I tried the following but it is not accessible in the scope of my component class:
我尝试了以下内容,但在组件类的范围内无法访问它:
Yii::app()->controller->getId
8 个解决方案
#1
44
Yes you can get the current controller/action
route, by reversing urlManager
rule:
是的,您可以通过反转urlManager规则获取当前控制器/操作路径:
Yii::app()->urlManager->parseUrl(Yii::app()->request)
更多相关文章
- mySQL库编码,PHP页面编码和mysql_query("set names 'GBK'")编码问
- 从模型到控制器并返回到模型的数据
- 我需要PHP页面显示mysql数据库中的BLOB图像
- InnoDB辅助索引页面的物理结构是什么样子的
- MySQL内核解析:Innodb页面存储结构-1
- 有没有办法阻止使用类似Firebug的工具在页面中编辑HTML和CSS内容
- 将JSON ID键插入到ng-click指令中,然后将其传递到另一个控制器
- 与同一页面上的两个jquery datepickers冲突
- 在Servlet和HTML页面之间处理函数调用和数据传输的最佳方法是什