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

5 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

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

Anonymous said...

thanks for sharing the information.Indian Cyber Army is announcing “ Summer Internship 2018” on “ Ethical hacking and Cyber Crime Investigation” for the enthusiasts of Cyber security. Here internship will give you on-the-job experience, help you learn whether you and Cyber security industry are a good match and can provide you with valuable connections and references. Here interns are usually exposed to a wide variety of tasks and responsibilities which allows the intern to showcase their strengths by working on projects for various managers that work on different parts of Indian Cyber Army. Becoming a high performing intern is a fantastic way to improve your employment prospects. This internship can be a great way to get your foot in the door of success with a prestigious or desirable Organization

Slim Chickens said...

I really like reading through a post that can make people think. Also, many thanks for permitting me to comment!

Panda Express Feedback

Shanthi Cabs said...

Thanks for sharing the post
Guest House Booking in Madurai | Guest Houses in Madurai