Thursday, July 5, 2012

Getting action/controller/module name in Yii

Some times we need to know the current controller/module/action name in our application, Yii provides the default methods to accomplish the tasks.

To get a controller name
Yii::app()->controller->id //or
Yii::app()->getController()->getId()
$this->id  here $this refers to current controller 

To get method/action name
Yii::app()->controller->action->id
You can get action name in controller
$this->action->id

To get module name
Yii::app()->controller->module->id
$this->module->id

3 comments:

Aasha said...


This blog explains the details about what happened after the expressions. This gives the

details of the thinking next what to do. All that are discussed and provide a grateful

talk
Digital Marketing Company in Chennai

Anil Gupta said...

The blog is absolutely truly incredible. Lots of large information and inspiration, both of which we all need.
Bangalore Web Designing Company, UI Designing Company Bangalore

Prasanth said...

Thanks for the information.Helped us to convince most on how this process work and what they could achieve by following these guidelines.
UI Designing Company in Bangalore, Web Application Development Companies in Bangalore