Do you want to create a new page in Magento ? or Do you want to create a new module in Magento ? If yes, Then ok, just spend 10 minutes and follow below steps.

Objectives: I will create a new page in Magento whose output will be “Hello World ! I am a Magento Guy..”.

Target: Create a new module called “HelloWorld”

Step 1: Module Declaration

Create app/etc/modules/M4U_HelloWorld.xml and write below code





true
local



Step 2: Module Configuration

a. Create a controller class app/code/local/M4U/HelloWorld/controllers/IndexController.php

class M4U_HelloWorld_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout(array('default'));
$this->renderLayout();
}
}

b. Create a Block class app/code/local/M4U/HelloWorld/Block/HelloWorld.php

class M4U_HelloWorld_Block_HelloWorld extends Mage_Core_Block_Template
{
// necessary methods
}

c. create configuration xml in app/code/local/M4U/HelloWorld/etc/config.xml






0.1.0





M4U_HelloWorld_Block_HelloWorld







standard

M4U_HelloWorld
helloworld






helloworld.xml





Define Frontend Template :

1. Define page layout in app/design/frontend/M4U/default/layout/helloworld.xml

N.B: Use default instead of M4U as template location if you use default design packages. Means create file in app/design/frontend/default/default/layout/helloworld.xml












2. Create template file app/design/frontend/M4U/default/template/helloworld/helloworld.phtml and write down

N.B: Use default instead of M4U as template location if you use default design packages. Means create file in app/design/frontend/default/default/template/helloworld/helloworld.phtml

Hello World ! I am a Magento Guy..

Hey, new module is ready to run and hit browser with url http://127.0.0.1/projectname/index.php/helloworld/

and see result.



http://xpertshelp.com/create-new-module-%E2%80%9Chelloworld%E2%80%9D-%E2%80%93-in-magento.html

創作者介紹

佳佳的窩

天秤女~佳佳 發表在 痞客邦 PIXNET 留言(0) 人氣()