Yii::app()->controller->id works fine when calling it from a view and from Controller.php
however
[b]
Yii::app()->controller->action->id[/b] works fine when calling it from a view but doesn’t work when calling from Controller.php. Yii::app()->controller->action returns null in Controller.php
I am using afterAction() inside modules controllers in yii1 , but its not getting working, how can I check and use it, any brief explanation will be appreciated.
No, it means you cannot get that information before the controller i initialized (init()). What you can do is override the init() function in your controller, call the parent init function from there, and then you get the action id. Example code inside your controller:
function init() {
parent::init(); // calling parent/Controller init function
// your code below here:
}