How to create a magento controller in magento extension

1. How to Create A Controller in Magento Extension Bippo CommerceCreating your own pages in Magento.
2. URL Structurehttp://demo.bippo.co.id/module/controller/action
3. Create Modules etc/config.xml 1.0.0
4. Activate in etc/modules/ {company}_{module}.xml true community
5. Controller Class PHP Codeclass Bippo_MyBanner_Display Controller extends Mage_Core_Controller_Front_Action{ public function showAction(){ }} Bippo/MyBanner/controllers/DisplayController.php

6. Router Config… standard Bippo_MyBanner display … Bippo/MyBanner/etc/config.xml
7. “Raw” Action
8. Testpublic function helloAction(){ echo “Hello World”;}
9. Test it http://localhost/magento/mybanner/display/hello
10. Layout-based Action
11. Layout Config mybanner.xml Bippo/MyBanner/etc/config.xml
12. Layout XML bippomybanner.xml
13. Load Layout in Actionpublic function smallAction(){ $this->loadLayout(); $this->renderLayout();}
14. Test /mybanner/display/small
15. Get URL from PHP
16. Process Input
17. Is Form POST ?$this­>getRequest()­>isPost()
18. Process POST Parameterspublic function multiplyAction(){ if ($this->getRequest()->isPost()){ $int1 = $this->getRequest()->getPost(int1); $int2 = $this->getRequest()->getPost(int2); $result = $int1 * $int2; Mage::getSingleton(customer/session) ->addSuccess(“$int1 * $int2 = $result”); } $this->loadLayout(); $this->_initLayoutMessages(customer/session); $this->renderLayout();}
19. Support Messages Block$this­>_initLayoutMessages(customer/session);Other choices: adminhtml/session catalog/session checkout/session
20. Add Message Mage::getSingleton(customer/session)­ >addSuccess(“$int1 * $int2 = $result”);
21. Display Message in PHTML Templateecho $this­>getMessagesBlock()­>getGroupedHtml();
22. References http://blog.baobaz.com/en/blog/magento­module­create­your­own­controller

We got this blog from www.slideshare.net for blog more information Click Here

Leave a Reply