How to find out what is the current controller and method?

I have some menu items and would like to highlight the current menu item. For example, I have menu item that links to post/list/?categoryID=5

What is the easiest way to know:

  • Current controller is Post
  • Current method is List
  • Current categoryID is five?

Yii::app()->controller->id and Yii::app()->controller->action->id give you the first two pieces of information. You will need to solve the last problem by your own.

great, thanks.

A note for those interested.

If your controller is under a module, e.g. admin/index

Yii::app()->controller->id only returns 'index', if you want to get the full controller name, you should use

Yii::app()->controller->UniqueId, which returns 'admin/index'