diaper cake

Magento® First Module

How to create Magneto frontend (Hello World) module??

  • Step 1. Create Global Configuration File
  • Step 2. Create Module Configuration file
  • Step 3. Create Module Frontend controller
  • Step 4. Create Module Frontend Layout file
  • Step 5. Create Module Frontend Template file


Step 1. Each Module should have one Namespace & Module name. Name space could be some company name etc. & module name should be something that represents module functionality. So let suppose Namespace is ExtendTree and Module name is FrontendModule. Now Create Global Configuration File inside root directory /app/etc/modules as name "ExtendTree_FrontendModule.xml"


<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <ExtendTree_FrontendModule> <active>true</active> <codePool>local</codePool> </ExtendTree_FrontendModule> </modules> </config>


Step 2. Now Create Module Configuration File inside the directory /app/code/local/ExtendTree/FrontendModule/etc as name "config.xml"


<?xml version="1.0"?> <config> <modules> <ExtendTree_FrontendModule> <version>0.0.1</version> </ExtendTree_FrontendModule> </modules> <frontend> <routers> <frontendmodule> <use>standard</use> <args> <module>ExtendTree_FrontendModule</module> <frontName>helloworld</frontName> </args> </frontendmodule> </routers> <layout> <updates> <frontendmodule> <file>extendtree/frontendmodule.xml</file> </frontendmodule> </updates> </layout> </frontend> </config>


Step 3. Now next thing is to create frontend controller inside the directory /app/code/local/ExtendTree/FrontendModule/controllers as name "IndexController.php"


class ExtendTree_Frontendmodule_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(); $this->renderLayout(); } }


Step 4. Now create frontend layout file inside the directory /app/design/frontend/base/default/layout/extendtree as name "frontendmodule.xml"


<?xml version="1.0"?> <layout version="1.0.0"> <frontendmodule_index_index> <reference name="root"> <action method="setTemplate"> <template>page/1column.phtml</template> </action> </reference> <reference name="content"> <block type="core/template" name="frontendmodule" template="extendtree/frontendmodule.phtml" /> </reference> </frontendmodule_index_index> </layout>


Step 5. Last step is to create frontend template file inside the directory /app/design/frontend/base/default/template/extendtree as name "frontendmodule.phtml"


<h1><?php echo $this->__('Hello World..!!')?></h1> <h2><?php echo $this->__('I just Created my first magento frontend module.')?></h2>


That's it..!! Now just run your module by URL as "YOUR_SITE_BASE_URL"/helloworld


Click here to get this module for free.



Thank you..!!

"The easy way for everything."