Magento 1.9 - My first simple module to print "Hello Aftab !"

Below are the steps to create module to print "Hello Aftab !"
Step 1. Create: app/etc/modules/Aftab_Hello.xml put:
1
2
3
4
5
6
7
8
9
<xml version="1.0"?>
<config>
    <modules>
        <aftab_helloaftab>
        <active>true</active>
        <codepool>local</codepool>
        </aftab_helloaftab>
    </modules>
</config>
Step2. Create: app/code/local/Aftab/Helloaftab/config.xml Put:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?xml version="1.0"?>
<config>
    <modules>
        <aftab_helloaftab>
            <version>0.1.0</version>
        </aftab_helloaftab>
    </modules>
    <frontend>
        <routers>
            <helloaftab>
                <use>standard</use>
                <args>
                    <module>Aftab_Helloaftab</module>
                    <frontname>helloaftab</frontname>
                </args>
            </helloaftab>
        </routers>
        
        <layout>
            <updates>
                <helloaftab>
                    <file>helloaftab.xml</file>
                </helloaftab>
            </updates>
        </layout>
    </frontend>
    <global>
            <blocks>
                <helloaftab>
                    <class>Aftab_Helloaftab_Block</class>
                </helloaftab>
            </blocks>
    </global>
</config>
Step3. Create: app/code/local/Aftab/Helloaftab/controllers/IndexController.php Put:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Aftab_Helloaftab_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        //echo "Hello Aftab !";
        $this->loadLayout();
        $this->renderLayout();
    }
    
    public function arshadAction()
    {
        //echo "Hello  Arshad !";
        $this->loadLayout();
        $this->renderLayout();
    }
}
Step 4. Create: app/code/local/Aftab/Helloaftab/Block/helloaftab.php Put:
1
2
3
4
class Aftab_Helloaftab_Block_Helloaftab extends Mage_Core_Block_Template
{
    
}
Step 5. Create: app/design/frontend/YOUR_THEME_PACKAGE/YOUR_THEME/layout/helloaftab.xml Put:
1
2
3
4
5
6
7
<layout version="0.1.0">
    <helloaftab_index_index>
        <reference name="content">
            <block name="helloaftab" template="helloaftab/helloaftab.phtml" type="helloaftab/helloaftab">
        </block></reference>
    </helloaftab_index_index>
</layout>
Step 6. Create: app/design/frontend/YOUR_THEME_PACKAGE/YOUR_THEME/template/helloaftab/helloaftab.phtml Put:
1
echo "Hello Aftab !";
Step 7. http://you-site-url/helloaftab/index/ Or http://you-site-url/helloaftab/index/index

No comments:

Post a Comment