In most of the case you need to know
the name of controller or module in order to debug. Simple one line code to get
these.
1. Get Controller Name In Template
Files:
$this->getRequest()->getControllerName();
2. Get Action Name In Template
Files:
$this->getRequest()->getActionName(); //the function inside the controller
3. Get Router Name In Template
Files:
$this->getRequest()->getRouteName();
4. Get Module Name In Template
Files:
$this->getRequest()->getModuleName();
Finding Controller, Module, Action
& Router Name In Class Files:
5. Get Controller Name In Class
Files:
Mage::app()->getRequest()->getControllerName();
6. Get Action Name In Class Files:
Mage::app()->getRequest()->getActionName();
7. Get Router Name In Class Files:
Mage::app()->getRequest()->getRouteName();
8. Get Module Name In Class Files:
Mage::app()->getRequest()->getModuleName();
These functions i.e.
getControllerName, getActionName, getRouteName, getModuleName are present in
the class Mage_Core_Model_Url, you can display all the results by taking a
vardump as
var_dump(Mage::app()->getRequest());
var_dump(Mage::app()->getRequest());
Hope this make sense to you and help
you in debugging. Happy coding..:)
No comments:
Post a Comment