Our Blog

BUILDING A MODULE IN MAGENTO

We build a simple module here. This will display simply “hello world”.
First create some directory
App/etc/modules/HelloWorld_HelloModule.xml
App/code/local/HelloWold/HelloModule/etc/config.xml
But this is not enough we need some other files also

Explanation:
Every module start with “<config>” and also end with “<config>”.
It has sub element named “<modules>”.it hold the definition of module. Under this we have our module declared as “<HelloWorld_HelloModule>”.
It is a practise to call your modules by MyCompanyName(HelloWorld) plus TheModuleItSelf. There are three places in the system where modules can resides in root: /app/code/community/(this), /app/code/core/(it is magento’s core file),
/app/code/local/(we declare our customized module ) folders.
The sub element “codePool” element has Its value is currently set to “local”, that’s meaning our new module config instructed the module to look for module files in /app/code/local/ folder.
Whereas “<HelloWorld_HelloModule>” element is a mapping to /app/code/local/ HelloWold/HelloModule / location.

It is the Base file of our module. By this file we can see our module at admin under
Admin -> system-> configuration -> advanced-> advanced
Now we have our module as “working”.
Now we expand this file to giving some extra parameters to “turn on” so controllers can call from frontend
Edited file
<?xml version="1.0"?>
<config>
<modules>
< HelloWorld_HelloModule >
<version>0.1.0</version>
</ HelloWorld_HelloModule >
</modules>
<frontend>
<routers>
< HelloWorld_HelloModule_SomeFreeRouterName1>
<use>standard</use>
<args>
<module> HelloWorld_HelloModule </module>
<frontName> HelloWorld-HelloModule </frontName>
</args>
</ HelloWorld_HelloModule_SomeFreeRouterName1>
</routers>
</frontend> </config>
Now we use this file in controller and make as use .
Controller directory
app/code/local/ HelloWorld/HelloModule /controllers/….

The controller we call from frontend .
In this file an element is called “frontend” which defined routers.
Routers are some additional parameters.
Here HelloWorld_HelloModule_SomeFreeRouterName1 is router name.

Parametar “use” havinf value “admin” or “standard”, while element “args” holds two additional parametars which is “module” and “frontName”. Element (param) “frontName” is defines the url on so we can access the controller.
example, if I were to open url http://............/index.php/ HelloWorld-HelloModule r I would see “Hello developer…”. And if I were to open http://..../index.php/ HelloWorld-HelloModule/index/sayHello I would see ‘Hello one more time…’;