1

I need to create multiple controllers in one custom module of me. How do I define all of them in my xml file.

1
  • For a better help paste you config.xml and controller code in the question with proper file path.
    – Mukesh
    Commented Jun 8, 2015 at 13:35

3 Answers 3

2

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

1
  • 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
0

You just need to create another controller file in controllers folder of your module like this: Yourmodule/controllers/AnotherController.

3
  • 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 :)
    – HungDQ
    Commented Jun 10, 2015 at 2:56
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.