yii中获取当前模块,控制器,方法

在控制器里

$name = $this->getModule()->id; // module

$name = $this->getId();  // controller

$name = $this->getAction()->id;  // action

在视图里,除了上述2个方法还可:

$name = $this->module->id; // module

$name = Yii::app()->controller->id;  // controller

$name = $this->getAction()->getId(); // action

 

posted @ 2015-07-15 10:55  Sentiger  阅读(644)  评论(0编辑  收藏  举报