This is a brief listing of the steps I have taken to test a sample module in Magento
Make folder app/code/local/Schogini <——— this name can be your company’s name, this make a new name space so that your classes will not interfere with other classes of the same name.
Inside the above folder make a folder called Example app/code/local/Schogini/Example <—- here Example is the name of the module we will create
Now add the module xml file at app/etc/modules/Schogini_All.xml <— here this can be Schogini_example.xml but I will use Schogini_All.xml so that all my test module definitions can be added to the same file instead of cluttering the etc/modules folder with many files.
<?xml version=”1.0″?><config><modules><Schogini_Example><active>true</active><codePool>local</codePool></Schogini_Example></modules></config>
Now create two folders app/code/local/Schogini/Example/etc and app/code/local/Schogini/Example/Block
In the app/code/local/Schogini/Example/etc folder make a file like this
<?xml version=”1.0″ encoding=”UTF-8″?><config><modules><Schogini_Example><version>0.1.0</version></Schogini_Example></modules><global><blocks><example><class>Schogini_Example_Block</class></example></blocks></global></config>
And now create the block php class file at app/code/local/Schogini/Example/Block/Myview.php
<?php
class Schogini_Example_Block_Myview extends Mage_Core_Block_Template {public function myFunction(){return “Hello World!“;}}?>
Now make the view folder at app/design/frontend/default/default/template/example <– here you should figure out the correct template folder of your Magento store.
Inside this create the view file for the module block app/design/frontend/default/default/template/example/myview.phtml
<p>Schogini example:</p><?php
echo $this->myFunction();?>
We can enable or disable this module at Admin -> System -> Advanced
Module creation is over at this point.
Now! Edit any page where you will want this module to show its output!
I have tested the above module in the home page by Admin -> CMS -> Manage Pages -> Home and edited to add these lines somewhere at the bottom
{{block type="example/myview" template="example/myview.phtml"}}
Please not the name space “schogini” is not required in the above line..
Reload the Magento home to see your module in action!
Hi
ReplyDeletewell
your are gave nice information but I already knew and i create already this module and the more usefully to meMagento eCommerce.
I tried out your tutorial and it worked for me when I changed the config.xml to this
ReplyDelete0.1.0
Fido_Example_Block
The difference being in the tag I had to rename to just !! Hope, this note will help someone.
Magento Website Templates