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
<?xml version="1.0"?> <config> <modules> <M4U_HelloWorld> <active>true</active> <codePool>local</codePool> </M4U_HelloWorld> </modules> </config>
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
<?xml version="1.0"?> <config> <global> <modules> <m4u_helloworld> <version>0.1.0</version> </m4u_helloworld> </modules> <blocks> <helloworld> <rewrite> <helloworld>M4U_HelloWorld_Block_HelloWorld</helloworld> </rewrite> </helloworld> </blocks> </global> <frontend> <routers> <helloworld> <use>standard</use> <args> <module>M4U_HelloWorld</module> <frontName>helloworld</frontName> </args> </helloworld> </routers> <layout> <updates> <helloworld> <file>helloworld.xml</file> </helloworld> </updates> </layout> </frontend> </config>
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
<?xml version="1.0"?> <layout version="0.1.0"> <helloworld_index_index> <reference name="root"> <action method="setTemplate"><template>page/1column.phtml</template></action> </reference> <reference name="content"> <block type="helloworld/helloworld" name="hello" template="helloworld/helloworld.phtml"/> </reference> </helloworld_index_index> </layout>
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.
That’s it……..
Is it easy or not ? what you think ?
Coder, Please at first try yourself.
Ohh.., Still are you facing problem ? Lets download full module source code from left panel “BOX” section or let me know.
Note: I have upgraded HelloWorld module source code of BOX widget. So it will resolve the problem which was faced by some guys.
Hi,
Its not working with me. I have configure all the things as mention. But it doesn’t show “Hello World ! I am a Magento Guy..”.
It seems IndexController does work properly it calls default layout of megento. Url hellowrold working fine but output is as per need.
Hey, you may placed your design related xml and phtml files in app/design/frontend/M4U/default/ location. But you didnot assign right package name(M4U) in admin. So you should use app/design/frontend/default/default/ as template location. I updated post, please see again. Hope it will work. Otherwise let me know, i can send you code files.
can again send the how to create magento module in proper way
Hi,
I am having trouble getting this to work on my test store.
Any chance to get in touch offline and work on it together? I really need to get this running.
OK, how can i help you?
I am trying to develop a module – I think I followed all the steps correctly but nothing happens when I hit the URL. It would be great if I can contact you online – I can give you access to it so you can direct me to what is wrong – and off course I will pay you for your time. I could not fund an email to send you information directly.
Here i have been uploaded new module source code in left panel “box” section. Please download.
actually i am trying to create a module – i cant make a module can u help me how can create module in magento and what do module in magento.pls help??
where is eft panel “box” section?? plz explain how i made hello world extention in magento
I tried your example for the frontend only with my namespace but i get 404 error. Folder structure is http://img39.imageshack.us/i/screenshot1azv.png/
Your folder structure is ok, but you should assign your new design namespace as design package name in admin under configuration tab. I have tested my source code and works fine. You just try to follow my post, hope you will get result. Otherwise let me know details.
Hi Moinul,
Thanks for the quick response. I happen to find the error…
When i add the below lines in app/code/local/BW/HelloWorld/etc/config.xml i get the 404 error ELSE, i get a 2 column layout…
helloworld.xml
Any idea where is it going wrong?
Ok you can delete my previous comments as after following the exact codes, i got the example working… Thank you very much for posting and keep such an informative site online!!
Regards ,
Accilies
I like to develop a module.I followed your instructions .But when executing the module in frontend i got a error page in the browser.Could you provide me the right solution.
i downloaded the zip file and uploaded it into my folder . But still am getting the 404 error..
Please again see your file structure. I tested source code. I know everything is ok, just try to follow step by step. Hope you will get result. Otherwise explain details
First of all I want to thank the author for his wonderful effort on developing new module in Magento. Guys I have tested this module and It works perfectly. It worked for me in just single attempt. All you need to do is to “Follow the instructions VERY carefully”. Thats exacty what I have done.
Thanks
Jameel
Dear i have used the files provided by you, but i am able to access the heeloword module.
IT is showing Whoops, our bad… error.
Can you please help me?
also tell me one thing that .phtml file will be placed directly in template folder or we have to create a folder name helloworld and put into that folder.
Yes, you have to create new folder name helloworld. I know my code is ok. You follow my instructions and read carefully. Hope you can do it.
I did use your exact guidelines. And tried the source code of yours too (there you have put the .phtml file directly in template folder). Tried in both ways.
But I get the 404 Not found error.
I am using foo2 theme. So i did put thoses 2 files in f002 instead of default and tried. but it dont work. Even I did put them in default folder as in yours, but still it dont work, why is it?
Thanks
I did use your exact guidelines. But I get the 404 Not found error.
version could be a problem?
thanks
Pingback: Magento, Magento, Magento « Redbeard Technologies Software and Systems Development Blog
Will try this, thanks for blogging it.
What might be the cause for some ppl not to be able to get this to work, is all the in Step 1. I’m pretty sure this is not correct. 🙂
Sorry, the software has removed my tags. 😉 What I wanted to say is, there are br’s in the XML-File.
Hello All, I have updated source code. Hope It will resolve the problems which have been faced by some guys.
Thanks
This code is working fine without any error.
Thanks,
I have followed exactly the directions in your post, but I still get 404 error.
I am using XAMPP on Windows 7 and vhost to modify URL
from
http://127.0.0.1/magento/index.php/helloworld
to
http://magento.local/index.php/helloworld.
I am really appreciated if you give me any ideas?
Thanks,
Sorry, I forgot clear the cache folder. It works perfectly now.
You can help me by deleting the previous comment.
Thank you,
Hello all,
This code is working very fine in fresh magento setup. I have one customized website in magento, In which different package name (Not a default package name). So this module is not working.
Please give me some solution or advice.
Thanks in advance,
Jigs
This module in my system is showing Controller file is loaded but class does not exist
Can somebody or moil explain what could be the problem .
But i have do that
Thanks
Jignesh Can you help , In my default package it is not working , please read the above comment of mine
Thanks
Prakash
Anyone can give me his gmail or yahoo id to tell me what could be the problem i would be very thankfull to him
Thanks
Prakash
Hi,
I was followed exactly what you wrote above, but always I was redirect to 404 error page.
1. Go to System->Cache Management
2. Select Refresh from the All Cache menu
3. Click Save Cache settings
After doing this its stared to work!. You have to add this also in this post for newbies like me.
Many thank and regards,
San.
This indeed solves the 404 page problem.
yes, that was the same problem I faced
Prakash,
I got this error when there were not opening PHP tags () in my IndexController.php and HelloWorld.php files.
Dada, ami Dhrubo. ami khubi bipod-e porci, amar admin-e ekta module add korte hobe, apni to module add kora dekhaichen, kintu oi module ta admin-er menu item hisebe kivabe add korbo dekhan nai,jodi ai bepere help koren tahole vai amar jonne khubi lav hoy,
Thankx to the author….guys its working fyn….initially i got sme problem like whoops ,bad…but then i refreshed cache and everything went alrite……if u r facing the same just refresh ur cache….
Hi Preeti,
Thanx for sharing the information
TIA
Dushyant Joshi
dushyantjoshia@gmail.com
Hey man, you have a great blog, I am currently working on the magento project with multiple seller/merchant account facility. I have a very hard time doing all these because I am new to Magento. So I really could use your help. can we work on this together online. it would be a great help for me.
Hey, It works for me, praise the lord. Thanks for all.
In addition to above steps, I have created page from admin side (CMS->Managepages) and used this code {{block type=”catalog/product_new” template=”helloworld/myview.phtml” }} to view to my custom module in browser.
I think you are all known about this, since I am new to CMS tools, I didn’t get idea
Great Tutorial Mate!
But can you please describe little bit more if we want to add a big module in Administration!
Actually i am building this getmybrand.com website and need to add new module within its front end and back end!
Any help would be appreciated!
Regards,
Raj
actually i want to make a module in magento but not creating me can u help????
Thanks a lot man.At first it didn’t workout but after clearing the cache it works fine. Great post. keep it up…..
Pingback: ::World Web Corner:: Simple for human::
Gratz man! It’s working! Grate job! Very, very thanks!
All work!
Recache all in adminCP!
Hello Binod. How are you would how are you getting on with your multi seller /vendor extension in Magento? Please let me know.
Hi , I like your module tutorial but it lacks explanation like in XML files.
you r super.thanks
just follow instruction and download folder.it will work
it is possible to copy the viewAction from CatalogController.php to create new view of view.phtml into newname.phtml i have created copy of viewAction to reveiwAction and also it was run good by using
http://local/catalog/category/review/id/6
but i have created new template review.phtml
then which part we want to change in the catalog.xml file 😦
Thank you very much!
It work well! This tutorial saves me much time 😉
hi image zoom not working in magento anyone help me
Hi
I copied everything without doing any changes but I got the same error as I got with the other tutorial: http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-3-magento-controller-dispatch/magento-for-dev-part-1-introduction-to-magento
you can check it out: http://bit.ly/cdJ5SA
thank you
does anyone have an idea?
I managed to make it work with the file posted in a comment here :
http://bit.ly/cdJ5SA
Hi Moinul Islam,
I have follow the your instruction it should be work on admin panel is fine.but still now i am not getting front-end display.i have hit this url http://127.0.0.1/projectname/index.php/helloworld/ at the time browser page automatically re-direct to the admin home page or login page i am not getting my result.Please help me.
Remember to God before doing any work
Than it will be all is well !!!1
Thanks Moin Bhai …!!!
extremely stupid explained. not understandable:(
Thanks It is working . Can u guide me how i can access magento table data. Thanks in advance
Great guide, I found it very useful 🙂
Hey Thanks………. Its Working
Hi
how i can call helloword.phtl output in any of page.
Just as a side note. After some 1/2 a day I found that on a multilingual Magento Installation the modules shows as 404 error when accessing as
/index.php/
but works fine as
/index.php//
e.g. /index.php/gb/MyModule/
(Magento 1.4.1)
I hope this saves someone some time ….
This is working fine but i want to add another module in my magento site.
i have created another Module just change the Name means that I have replaced “HelloWorld” to “CategoryDescription” but this module is working. if u have any idea then tell me please.
This is working fine but i want to add another module in my magento site.
i have created another Module just change the Name means that I have replaced “HelloWorld” to “CategoryDescription” but this module is not working so please help me……….
Assalam o alaikum
JazakAllah, bundle of thanks
it works fine for me:)
Regards
Pingback: To add a module in magento « Venkatraja's Blog
Pingback: Magento Themes and Magento Extensions Create new module “HelloWorld” – in Magento
thanks..!! Nice… one…
I googled but after some find this tutorial.Its really a nice tutorial.
Thanks
thanks for post this artical
Nice works dudes. It works.
keep sharing.
Thanks… a lot…………..
i have face some error . the error details
There has been an error processing your request
Exception printing is disabled by default for security reasons.
Error log record number: 921930541
please send me solution to the problem
thank you
Thanks….. it works good
this is very clean way to explain each and everything
thanks a buddy
Nice one, i dont know why Magento documentation is so bad,
I have to learn it from blogs like yours.
Do you know any good reference book worth buying it?
Thanks!
worked perfectly ! nice article. keep them coming
I’m newbie in Magento. How to add new page on customer account dashboard? I’m used Magento ver. 1.5.0.1
Thank You
Yudha
The best magento module tutorial ever men.
Hi Folks,
Thanks for this tutorial, I shared it with a friend as it was really useful.
I just wanted to say that a couple of the problems above, especially the controller class error could be caused if you don’t have a <?php declaration at the top of each php file.
Cheers,
Simon Rowland (software engineer @ Singing Horse Studio).
thank you man
Shukriya Bhai Jaan
The great tutorial.if any body found the “magento 404 not found1” error then please refresh your cache using the link given in admin panel.
Thanks again.
Thanks, Its working for magento 1.5.0.1
Pingback: How to make a custom Magento payment extension for an external gateway « Junaid Bhura : Freelance web developer and consultant specializing in PHP-MySQL, XHTML-CSS and Open Source technologies
Hi I have used your exact guide line but now it is show error 404
thanks for this tutorial, i’ve made a list of tutorials to do more:
http://www.about-magento.com/magento-developper-guide-howto-tutorial-5
i hope it will help.
Pierre FAY.
Thanks Moinul, you have posted a very benificial tutorial specially for the beginners. The best part is that each and every line has been described in a neat and clean way.
hey thanks a lot… 🙂 it worked at first try.. 🙂 awsome way to explain to ccreate a new page/module .. Thanks a tonn again
hi,
i’m a complete beginner to magento, and a little rusty with php.
i’m currently not getting past the 404 stage, though initially i did get a template page but without anything in the main body of it.
can you suggest whether it would be a problem that i built the magento folder (using the downloader wizard) directly into the /var/www root, so when you say to navigate to http://127.0.0.1/projectname/index.php/helloworld i don’t have a projectname component to my path. I currently have to browse to http://servername/index.php to start my magento.
thanks if you can understand this and advise if it is a problem.
jonathan
Thank you mister, this is really great.
I really appreciate this, especially your effort for
creating and uploading HelloWorld.zip in Box. It is so much
easier to start when you have referent example.
jonathan: look at http://www.about-magento.com/magento-create-block-44
Pingback: Using Silverstripe as CMS behind Magento – Part 2 | 16is10
Thanks for the post, I downloaded the module and it works.
But for me is very confused because you are using “helloworld” for everything (name of the module, name of the block file, name of the block class, name of the template etc) so I don’t know what are you referencing exactly in the xml files.
For example , if I can change block class name from M4U_HelloWorld_Block_HelloWorld to M4U_HelloWorld_Block_HelloWorld2 (I just added a “2” in the end)…What files and what configuration code should I change?
Thanks
Great…Its Working…Really Good…
Thank you soooo much for such a Nice help…
hi,
i’m a complete beginner to magento, and a little rusty with php. it is really good to me it s work for me .
but i want to show only our message without anything i.e. header ,left, right and footer
what should i do for this
Thanx your code is working fine
The code in your source files is completely different to that displayed on the page…
Thanks dude, It really helps me… Thanks alot for posting this kind of useful code.
Hello.
the working of my module in localhost is fine but when we upload into the server its gives the same error 404 not found. WHY?
Please help me its very urgent
Thanks
done thanks
I have used same file structure as you describe over here and also clear the cache but still don’t show any message on screen.
I am using magento 1.
Thanks for this article, It’s very useful for new developers who learn about magento Modules.
Hi … just a query!
when I declare block class tag and without rewrite just as this it doesn’t work
blocks
test
class>M4U_HelloWorld_Block</class
/test
/blocks
blocks
Could you plz explain this behaviour?
Thanks
Noush
Thanks for the Article it worked… Thanks a lot..
I follow all the steps Rigth
as Pin_Api. I hit the url don’t get any error.But no message in the page.It was blank…..any help
Thanks.
download the latest file from the right side box.then place them in proper folder hope it will work
Hi friends,
i have trouble multi-currency with Paypal configuration .
Advance thanks
Pingback: How to make a custom Magento payment extension for an external gateway | Junaid Bhura - Wordpress, Magento web development studio Bangalore
those who get page not found error 404 then goto admin side system->catch management-> and clear all catch and refresh front side
You need to put in the controller.
Pingback: Module Development Magento « rajeshgoudblog
Pingback: Magento Custom Module Creation « rajeshgoudblog
I follow all the steps given above.. but when executing, it shows 404 not found 1 error message. and also in admin page when click “advanced” link it does not show M4U_HelloWorld to know the status “active” or “deactive”..
clear magento cache.
Friend,
Its working fine but when we upload into the server its gives the same error 404 not found.
Thanks .
Just clear magento cache then try again. Thanks
Thanks ..
I want create new block in magento can you help me ?
it is executing properly !!!!
thanks….
nice one …
it got executed 😉
thanks . . . .
I wrote this module 3 times… The 1st time I got a blank magento page, I thought it was an error I made. I rewrote it 2 more times, with the exact same result. If I enter the URL address it does not give me 404, it just gives me the blank page. If I change a character in the URL it correctly gives me error 404. I cleared the cache via the console and the system, and in both cases it still just gives me a blank page.
I am running Windows x64, with the latest WAMP and latest magento install files, am I missing something?
After a rewriting this and getting the same result I am very close to giving up with Magento, I switched browsers from Chrome to Firefox, okay now I can login to the /admin section.
I type the URL to access it, and it does not say 404 not found, it simply gives me a blank Magento page with no content. I follow the steps, and just keep getting the same problem am I missing something?
m follow all stem and run the code but it`s not working please help me and m using magento 1.5 version……………..
I use enterprise with multiple stores, and I cannot get this to work.
I’ve tried clearing the cache. It just simply won’t work.
Magento ver. 1.12.0.2
Thanks for the tutorial its worked after i put all the file from box.you may edit your tutorial so people can fix it first time without downloading your source code.and give some simple explanation of each Blocks function.
Thanks again 😉
Great!!. It is working fine. In the first time itself I got the correct out put just after clearing cache. Thank you. Keep on update such great tutorials..
I had read all the thread, flushed the cache, but it’s still throwing the 404 error… My magento version is 1.7 (maybe it’s matters?)
Thanks for this article, It’s very useful for new developers who learn about magento Modules.
hey hi moinul
I used ur source code.exact i follow ur steps.but i occure following error
“404 error not found or configure”
hey hi
tell me the role of following folders
1.Block
2.Helper
3.Controller
4.etc
5.Model
this module is not showing helloworld.phtml file’s data on frontend.
After clearing cache, I am being redirected to error page: (/errors/report.php) Where it is saying:
There has been an error processing your request
Exception printing is disabled by default for security reasons.
Error log record number: 1056778645540
You didn’t answer @dinesh comment for the same issue: https://magento4u.wordpress.com/2009/06/08/create-new-module-helloworld-in-magento/#comment-364
Sir My controller not calling layout that define in my theme frontend/default/wiper/default/layout/helloworl.xml and (wiper is my default theme). when i goes to http://localhost/magento/index.php/helloworld/ display nothing.
but when i echo some thing in my function indexAction{
echo “this is index function”;
}
“this is index function ”
This will show rather than showing block info.Please Help me I am new in magento. Thanks In Advanace.
great ……………..
Hey Moinul,
Very nice Article, it would have been nice if you can also elaborate the naming conventions and what each XML tags are for..
ex –
M4U_HelloWorld_Block_HelloWorld
here this tag refers to frontname, classname, modulename, blockname.. its a bit confusing.. if you can just explain those, it will be really helpful.
Tnx !!! It’s working 🙂 my first magento module
hey hi…. thanx for this code…. but i tried to go thrugh the link as u said… bt its nt working… its showing me……
Whoops, our bad…
The page you requested was not found, and we have a fine guess why.
so plz help me out…… i m waiting for ur reply….. 🙂
check it now. Thx.
Reblogged this on Magento Tips and Fundamental Solutions.
Pingback: How to start Magento ecommerce development ? – for Beginner | Magento-4U
hello everyone,
can any one suggest me, any best advanced ajax cart extesion for magento.
You can check Aheadwork ajax cart.
http://ecommerce.aheadworks.com/magento-extensions/ajax-cart-pro.html
Thanks working perfect for me.
I tried all these tips given above but still It shows 404 error.
Hi,
Every body are talking about a zip file which they downloaded and made them happy! Is there any link?
I really like it when folks come together and share ideas.
Great blog, keep it up!
Hello am using Magento 1.8version am trying to display Goldrate Module table display on menu category but i do not know how to do that where to put to coding can u please help me
hello, i add this module in magento 1.8.1.0 but when i see the page then display only “class M4U_HelloWorld_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(array(‘default’)); $this->renderLayout(); } }” and There has been an error processing your request ……this type of error
Good tutorial ,Thanks a lot 🙂
Its working with defautlt theme package .But its not working in my custom template package ? Iam beginer to magento . Please help me 🙂
Sorry for trouble , its my mistake now working fine thanks a lot 🙂
Still no download link?
Hello, can i get a quick help from you, i am integrating new theme on the existing store but not able to migrate 2 existing modules from old template. Ready to payout, if you wish.
I am on magento 1.8 and i fixed my 404 error by doing the following. inside Magentotutorial_Helloworld.xml they tell you to put this code in “local” since i do not have a local folder i put mine into the community folder. Change the code to this and it will work. “community”
inside the xml
codePool inside XML.
Guys i have a solution for all of you who are facing problems.
you just need to change the directory structure for helloworld.xml and
helloworld.phtml as follows.
app/design/frontend/base/default/layout/helloworld.xml
app/design/frontend/base/default/template/helloworld.phtml
Everything is very open with a clear explanation of the issues.
It was definitely informative. Your website is extremely helpful.
Thanks for sharing!
Simplest modules ever, good for beginners, Thanks you for your sharing
Pingback: Fix Magento Error Log Record Number Location Windows XP, Vista, 7, 8 [Solved]
Pingback: Fix Magento Print Errors Windows XP, Vista, 7, 8 [Solved]
where i can find the downloading file ????
if its posible send me the file to this mail id blue.blacky@live.com…..
Thanks….!!!
pls let me know how i can upload this extension via Extension Manager in magento .
very effective and useful tutorial. Thanks Moinul. Proud to be a Bangladeshi.
I don’t see any download links 😦
“Lets download full module source code from left panel “BOX” section or let me know.”