Pages

Showing posts with label Magento Hello world module. Show all posts
Showing posts with label Magento Hello world module. Show all posts

Tuesday, May 6, 2014

Creating "Hello World" Magento Module

To start with a new Magento module, you have to create a module code folder under an appropriate code pool.
Lets create "Hello World" module module.

Step 1:

- Please create ".xml" file for module as below:
\app\etc\modules\Demomodule_Helloworld.xml

<?xml version="1.0"?>
<config>
<modules>
<Demomodule_Helloworld>
<active>true</active>
<codePool>local</codePool>
</Demomodule_Helloworld>
</modules>
</config>


Step 2:

Now, you have to create config file for module setup as below:

\app\code\local\Demomodule\Helloworld\etc\config.xml

<?xml version="1.0"?>
<config>
<modules>
<Demomodule_Helloworld>
<version>1.0.0</version>
</Demomodule_Helloworld>
</modules>
<frontend>
        <routers>
            <helloworld>
                <use>standard</use>
                <args>
                    <module>Demomodule_Helloworld</module>
                    <frontName>helloworld</frontName>
                </args>
            </helloworld>
        </routers>
        <layout>
            <updates>
                <helloworld>
                    <file>helloworld.xml</file>
                </helloworld>
            </updates>
        </layout>
    </frontend>
</config>


Step 3: 

Please create controller file with below information.

\app\code\local\Demomodule\Helloworld\controllers\IndexController.php

<?php
class Demomodule_Helloworld_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
$this->loadLayout();     
$this->renderLayout();
    }
}

Step 4:

Please create ".xml" file for plugin "Block" setup as below:

\app\design\frontend\default\default\layout\helloworld.xml

<?xml version="1.0"?>
    <layout version="0.1.0">
<helloworld_index_index>
<reference name="content">
<block type="core/template" name="helloworldpage" template="helloworld/content.phtml"/>
</reference>
</helloworld_index_index>

</layout>


Step 5:

Now, you have to create new ".phtml" file for your content as below:

\app\design\frontend\default\default\template\helloworld\content.phtml

<div class="banner-left box">
<?php echo $this->__('This is the demo "Hello World" module.');?>
</div>