I need to create multiple controllers in one custom module of me. How do I define all of them in my xml file.
3 Answers
You only need to set the Routes in your config.xml file:
<config>
...
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>Company_Helloworld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
</frontend>
...
</config>
Finally create the controllers you need in your module under the controllers folder:
app/code/local/Company/Helloworld/controllers/IndexController.php
For more info check this nice article: Magento Controllers
-
Hi here you create one controller indexController.php but i need to create another one controller PannelsController.php and then how to call and how to defined in config file this is Commented Jun 8, 2015 at 5:44
You just need to create another controller file in controllers folder of your module like this: Yourmodule/controllers/AnotherController.
-
Thanku for that but i have created another controller that is giving 404 not found error when i open in browser. can i have to define route also in config file. Commented Jun 8, 2015 at 9:42
-
here is my first and second controllers... Commented Jun 8, 2015 at 17:55
-
I think you should change your module name from PriceChange to Pricechange. Please let me know it's working or not :)– HungDQCommented Jun 10, 2015 at 2:56
here is my first and second controllers.
class YBizz_PriceChange_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo 'hello';
echo $filepath;
}
}
class YBizz_PriceChange_PanelsController extends Mage_Core_Controller_Front_Action
{
/*
* this method privides default action.
*/
public function indexAction()
{
echo 'hello panells';
exit;
}
}
and here is my config file front end
<frontend>
<routers>
<pricechange>
<use>standard</use>
<args>
<module>YBizz_PriceChange</module>
<frontName>pricechange</frontName>
</args>
</pricechange>
</routers>
</frontend>
How can define these controller in config file that which will be call.