Wednesday, May 2, 2012

Magneto Get Router.Controller,Module,Action Name

Generally we get confused while checking the controller name .so require to known name for the controller,router,module,action.Below are the following methods which will help to get the controllers ,action ..etc as per the need


IN TEMPLATE FILES
$this->getRequest() can be used

get Controller name
$this->getRequest()->getControllerName();

get Action name, i.e. the function inside the controller
$this->getRequest()->getActionName();

get Router name
$this->getRequest()->getRouteName();

get module name
$this->getRequest()->getModuleName();

IN CLASS FILES menas php files
$this might not work.In this case, you need to use Mage::app().

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();

This functions (getControllerName, getActionName, getRouteName, getModuleName)
are present in the class Mage_Core_Model_Url.

Hope this will help You....

No comments:

Post a Comment

Thankyou for your Comments

LinkWithin

Blog has moved, searching new blog...