Many time you need to get current controller or action name from Url during coding in yii.
Lets Take an example :
Suppose your current url in yii like below :
http://www.xyz.com/controllerName/ActionName/
http://dev.trademyway.com/trade/MyView
Now you want to get only action name(MyView) from above url ,then simply copy and paste below code
where you want to get
===>>> $this->action->Id; --------- This will get you current action name.
Now you want to get only controller name(trade) from above url ,then simply copy and paste below code
where you want to get
===>>> Yii::app()->controller->id -----This will get you current controller name.
If you like this post please don't forgot to notify me to post a comment .
Happy coding guys :)
Lets Take an example :
Suppose your current url in yii like below :
http://www.xyz.com/controllerName/ActionName/
http://dev.trademyway.com/trade/MyView
Now you want to get only action name(MyView) from above url ,then simply copy and paste below code
where you want to get
===>>> $this->action->Id; --------- This will get you current action name.
Now you want to get only controller name(trade) from above url ,then simply copy and paste below code
where you want to get
===>>> Yii::app()->controller->id -----This will get you current controller name.
If you like this post please don't forgot to notify me to post a comment .
Happy coding guys :)
Tags:
Yii framework