博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::



How to get current controller name and action name in Yii

By Dimi Low on July 7th, 2010 (6 responses)

To get current controller name/id inside your controller, or view
$controllerId = Yii::app()->controller->id;
$controllerId = $this->getId();

To get current action name/id being executed, if you are inside beforeAction() or afterAction(), use the received CAction argument
//inside beforeAction or afterAction
public function beforeAction($action)
$actionId = $action->id;
or just elsewhere inside your controller
$actionId = $this->getAction()->getId();

posted on 2013-02-17 10:53  jinhuawang76  阅读(167)  评论(0编辑  收藏  举报