In order to make a customization in Magento, developer must consider the following code to request the Module Name, Router Name, Action Name and Controller Name. Request for these names are important in debugging stage, customization or maintenance especially when you're not using a developer toolbar to track the magento file path.
Controller Name - Each Module with Controllers has a special folder named 'controllers' which contains all the Controllers for a module. In the above example, the URL portion category is translated into the Controller file.
Action Name - The action method name that specified in every controller For example, this is "view". The word "view" is used to create the Action Method. So, in our example, "view" would be turned into "viewAction".
Router Name - the code return the a routing name if there is no valid Controller / Action Name. It simply tell the path which you are routing with.
Module Name - the output will be the Module name where the page is located.
Take Note: If you're editing in Class File the $this may not work. You can try the following code to get the above request.
/*** get Controller name */ $this->getRequest()->getControllerName();
Controller Name - Each Module with Controllers has a special folder named 'controllers' which contains all the Controllers for a module. In the above example, the URL portion category is translated into the Controller file.
/** * get Action name, i.e. the function inside the controller */ $this->getRequest()->getActionName();
Action Name - The action method name that specified in every controller For example, this is "view". The word "view" is used to create the Action Method. So, in our example, "view" would be turned into "viewAction".
class Mage_Catalog_CategoryController extends Mage_Core_Controller_Front_Action { public function viewAction() { //main entry point } }
/** * get Router name */ $this->getRequest()->getRouteName();
Router Name - the code return the a routing name if there is no valid Controller / Action Name. It simply tell the path which you are routing with.
/** * get module name */ $this->getRequest()->getModuleName();
Module Name - the output will be the Module name where the page is located.
Take Note: If you're editing in Class File the $this may not work. You can try the following code to get the above request.
# get Controller name Mage::app()->getRequest()->getControllerName(); # get Action name, i.e. the function inside the controller Mage::app()->getRequest()->getActionName(); # get Router name Mage::app()->getRequest()->getRouteName(); # get module name Mage::app()->getRequest()->getModuleName();
2 comments:
Thanks for sharing about magento Controller. now a days magento ecommerce is providing in many more company it's having more demand and easy to handle. it's reaching very fast.
magento development
great, it really helps someone like me who is not a very computer literate person.
Post a Comment