So here is our
file and folder structure for module.
A) app\etc\modules\Summer_Spring.xml (Create
a file for Module Configuration file).
B) \app\code\local\Summer (Create a namespace
folder).C) \app\code\local\Summer\Spring (Create
a module folder).D) \app\code\local\Summer\Spring\controllers
(Create a controller folder).E) \app\code\local\Summer\Spring\etc (Create
a Configuration folder).F) \app\code\local\Summer\Spring\etc\config.xml
(Create a Configuration file).G) \app\code\local\Summer\Spring\controllers\IndexController.php
(Create a Controller file).
Step 1:- Create a module configuration file
to tell Magento about your module. So create a file in app\etc\modules\Summer_Spring.xml
in this file write following code:-
<?xml
version="1.0"?>
<config>
<modules>
<Summer_Spring>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Summer_Spring>
</modules>
</config>
Save “Summer_Spring.xml” there is no any rule for file naming you can put any
name for your file. I have to explain some above used code: -
A) “<Summer_Spring>”
where “Summer” is namespace
for our Module folder and “Spring” is our Module.
B) “<active>true</active>”
this code will activate your module. For disable module replace true by “false” .
C) <version>0.1.0</version>
this code used to set version for our module.
Ok now let’s create Configuration file in our module:-
Step 2:- \app\code\local\Summer\Spring\etc\config.xml
open the file and add the following code:-
<?xml
version="1.0"?>
<config>
<modules>
<Summer_Spring>
<version>0.1.0</version>
</Summer_Spring>
</modules>
<frontend>
<routers>
<Spring>
<use>standard</use>
<args>
<module>Summer_Spring</module>
<frontName>spring</frontName>
</args>
</Spring>
</routers>
</frontend>
</config>
Save “config.xml”. I have to explain some above used code: -
A) “<frontend></frontend>” in this
section we put the control from frontend.
B) “<Spring
></Spring >” Allows you to declare
a router « Spring » which is actually
the road used by magneto to access your controller. In our example, the router
is « standard » (it means that it is a module that will be displayed
on the frontend)
C) The module name is “Summer_Spring” and
the shortcut to access it via the url is “spring”
and when you will type “magentosite.com/spring/index”, this
will call to index method from our module controller IndexController.php.
So let’s create a controller for our module:-
Step 3:-
\app\code\local\Summer\Spring\controllers\IndexController.php
open this file and add following code:-
<?php
class Summer_Spring_IndexController
extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo “Hello this is test index”;
}
}
Save “IndexController.php” .Ok now I have to explain some above used code: -
A) “Summer_Spring_IndexController” this class name contain actual path to the file.
B) “
public function indexAction()” this is
our method which we will access it from front end.
So go to your site and type: - yourmagentosite.com/spring/index
That’s it thank You for reading.
So here is our
file and folder structure for module.
A) app\etc\modules\Summer_Spring.xml (Create
a file for Module Configuration file).
B) \app\code\local\Summer (Create a namespace
folder).C) \app\code\local\Summer\Spring (Create
a module folder).D) \app\code\local\Summer\Spring\controllers
(Create a controller folder).E) \app\code\local\Summer\Spring\etc (Create
a Configuration folder).F) \app\code\local\Summer\Spring\etc\config.xml
(Create a Configuration file).G) \app\code\local\Summer\Spring\controllers\IndexController.php
(Create a Controller file).
Step 1:- Create a module configuration file
to tell Magento about your module. So create a file in app\etc\modules\Summer_Spring.xml
in this file write following code:-
<?xml
version="1.0"?>
<config>
<modules>
<Summer_Spring>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Summer_Spring>
</modules>
</config>
Save “Summer_Spring.xml” there is no any rule for file naming you can put any
name for your file. I have to explain some above used code: -
A) “<Summer_Spring>”
where “Summer” is namespace
for our Module folder and “Spring” is our Module.
B) “<active>true</active>”
this code will activate your module. For disable module replace true by “false” .
C) <version>0.1.0</version>
this code used to set version for our module.
Ok now let’s create Configuration file in our module:-
Step 2:- \app\code\local\Summer\Spring\etc\config.xml
open the file and add the following code:-
<?xml
version="1.0"?>
<config>
<modules>
<Summer_Spring>
<version>0.1.0</version>
</Summer_Spring>
</modules>
<frontend>
<routers>
<Spring>
<use>standard</use>
<args>
<module>Summer_Spring</module>
<frontName>spring</frontName>
</args>
</Spring>
</routers>
</frontend>
</config>
Save “config.xml”. I have to explain some above used code: -
A) “<frontend></frontend>” in this
section we put the control from frontend.
B) “<Spring
></Spring >” Allows you to declare
a router « Spring » which is actually
the road used by magneto to access your controller. In our example, the router
is « standard » (it means that it is a module that will be displayed
on the frontend)
C) The module name is “Summer_Spring” and
the shortcut to access it via the url is “spring”
and when you will type “magentosite.com/spring/index”, this
will call to index method from our module controller IndexController.php.
Save “IndexController.php” .Ok now I have to explain some above used code: -
A) “Summer_Spring_IndexController” this class name contain actual path to the file.
B) “
public function indexAction()” this is
our method which we will access it from front end.
No comments:
Post a Comment