Monday, 26 December 2011

Create a module to display "Welocme to Veera Pradeep Blog" in Magetno

  

Step1. Telling Magento that we are creating new module
The first step is to tell magento that we are going to write a module called pradeep
under veera package name, which u can find in your local codePool.

Always start by writing below mentioned code in app/etc/modules/

syntax:- [your-package-name]_[your-module-name].xml
<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : Veera_Pradeep.xml.xml
    Created on : December 26, 2011, 4:47 PM
    Author     : V.V.N.Pradeep
    Description:
        Purpose of the document follows.
        In order to learn xml visit http://www.w3schools.com/xml/

        <config> XML documents must contain a root element. This element is
                 "the parent" of all other elements. you can give any name but,
                 best practice is to give the name <config>
                
        <active> element contain boolean value true/false
        In magento we have 3types of <codePool> value
        1. The first  <codePool> is  community is for third party
        module/extensions which you can download via magento connect
        2. The next <codePool> is core which contains magento inbuild module
          never ever try to modify any of these files.
        3. The last <codePool> is local. all the modules which we creted we
        should place here.
-->

<config>
    <modules>
        <Veera_Pradeep>
            <active>true</active>
            <codePool>local</codePool>
        </Veera_Pradeep>
    </modules>
</config>

<!--
    Description: you can enable or disable your module Output through backend
                 got to your admin panel
                 System->Configuration->Advanced->Disable Module Output
-->

/*************************/
Step2. Binding all the folder 

<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : config.xml
    Created on : December 26, 2011, 5:31 PM
    Author     : V.V.N.Pradeep
    Description:
        Purpose of the document follows.

        This configuration is used to bind the all folder
        inside the Pradeep module.

        <config> XML documents must contain a root element. This element is
                 "the parent" of all other elements. you can give any name but,
                 best practice is to give the name <config>
        <routers>  is parses a URL
        <use>standard</use>  There are three types of routers in magento standard, admin and default. We are telling magento use standard router for front end flow. admin for admin/back office functionality. 
        <frontName> can be any name, but best practice is
                    to keep your module name
-->

<config>
    <frontend>
        <routers>
            <pradeep>
                <use>standard</use>
                <args>
                    <module>Veera_Pradeep</module>
                    <frontName>pradeep</frontName>
                </args>
            </pradeep>
        </routers>
    </frontend>
</config>
/******************************/
Step3: Writng Controller
<?php
/*
 * @author  : V.V.N.Pradeep
 * @description --
 *    Purpose of the document follows.
 *   Magento is an MVC based framework. default controllers for an module is
 *   IndexController and default action is indexAction. you must always extend
 *   Mage_Core_Controller_Front_Action Why? Then google it
 */
?>

<?php
class Veera_Pradeep_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        echo "Welocme to Veera Pradeep Blog";
    }
}


/*
 * To see the output just type the url http://demo.com/magento/pradeep or
 *   http://demo.com/magento/pradeep/index/index
 *
 *    Syntax:-   http://demo.com/[frontname]/[controller name]/[action name]
 *
 * pradeep is your frontname which you mentioned in your config.xml
 * under <router> tag which parses the url.

 * How it parses the url google it.
 *
 *
 */


?>





2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hello pradeep,
    We need Magento Site development Can you??

    If yes mail me as soon as possible . " goodmails2u@gmail.com "

    ReplyDelete