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
    • 221
    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:

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

    myfirstmodule.info

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

    The .info file can contain the following properties:

    name /*required*/
    description /*recommended*/
    core /*required*/
    stylesheets
    scripts
    files
    dependencies
    package
    php
    version /*discouraged */
    configure
    required
    hidden
    project  /*discouraged, packaging use only*/
    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

    <?php
    /*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
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: