Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Creating Your First Module

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 233
    Comment on it

    Creating module is easy in drupal

    Steps you need to follows are as below.

    1. Creating the module directory
    2. Creating the .info file
    3. Creating the .module file

    Where does your custom module goes?
    Its always better to keep contrib and custom modules seperate. So your module should goes under custom folder site->all->modules->custom->

    under this folder you should have at-least two files .info and .module file.

    .info and .module should have the same name as your module folder name.
    example
    If you module folder name is myfistmodule then you should have myfistmodule.info and myfistmodule.module.

    Drupal uses .info files to store metadata about modules.

    For modules, the .info file is used for:

    1. rendering information on the Drupal Web GUI administration pages;
    2.  
    3. providing criteria to control module activation and deactivation;
    4.  
    5. notifying Drupal about the existence of a module;
    6.  
    7. general administrative purposes in other contexts.

    myfirstmodule.info

    1. name = My First Module
    2. description = Provides timezone handling
    3. core = 7.x

    The .info file can contain the following properties:

    1. name /*required*/
    2. description /*recommended*/
    3. core /*required*/
    4. stylesheets
    5. scripts
    6. files
    7. dependencies
    8. package
    9. php
    10. version /*discouraged */
    11. configure
    12. required
    13. hidden
    14. project /*discouraged, packaging use only*/
    15. project status url /*only used for custom modules not submitted to drupal.org*/

    More details about each property could be found on https://www.drupal.org/node/542202

    that's all you need in .info file

    myfirstmodule.module file contains your php code

    1. <?php
    2. /*Here is my first module */

    And this is all you need to create you first module in drupal.

    By now your module should be available in module list . where you can enable/disable it.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: