Friday, April 19, 2013

easly create a module in magento and uderstanding


Magento Create A Simple Module and easly
Are you looking to find out how to make a custom module for Magento? If you follow the steps below, you will be well on your way in under 15 minutes.
Steps– Declare Your Module


app\etc\modules\Phparrow_Hello.xml

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


Create a Controller Class app/code/local/Phparrow/Hello/controllers/IndexController.php
class Phparrow_Hello_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
     $this->loadLayout();
     $this->renderLayout();
    }
}
Create a Block Class app/code/local/Phparrow/Hello/Block/Hello.php
class Phparrow_Hello_Block_Hello extends Mage_Core_Block_Template
{
  // necessary methods
}
Create configuration xml in app/code/local/Phparrow/Hello/etc/config.xml
<?xml version="1.0"?>
<config>
    <global>
        <modules>
                <phparrow_hello>
                        <version>0.1.0</version>
                </phparrow_hello>
        </modules>
    <blocks>
            <hello>
                <rewrite>
         <hello>Phparrow_Hello_Block_Hello</hello>
        </rewrite>
            </hello>
     </blocks>
        </global>
       <frontend>
                <routers>
                        <hello>
                                <use>standard</use>
                                <args>
                                      <module>Phparrow_Hello</module>
                                      <frontName>hello</frontName>
                                </args>
                        </hello>
                </routers>
        <layout>
            <updates>
                <hello>
                      <file>hello.xml</file>
                </hello>
            </updates>
            </layout>
        </frontend>
</config>

Create Frontend Template
Define page layout in app/design/frontend/default/default/layout/hello.xml

<?xml version="1.0"?>
    <layout version="0.1.0">
        <hello_index_index>
            <reference name="root">
                <action method="setTemplate"><template>page/1column.phtml</template></action>
            </reference>
            <reference name="content">
                <block type="hello/hello" name="hello" template="hello/hello.phtml"/>
            </reference>
        </hello_index_index>
    </layout>

app/design/frontend/default/default/hello/hello.phtm
<?php

echo "any doubt contact through comment"

?>




No comments:

Post a Comment