Friday, February 4, 2011

Module Creating In Drupal

At minimal, create 2 kind of files:
1. hello.info
  name = Hello Module   ; this will appear in the module 
                        ; configuration and other display text
  description = A module for displaying text  
  package = My Module   ; categories your module
  core = 7.x

2. hello.module
   <?php
   /**
    * Implements hook_menu()
    *
    * Simply provide a menu entry
    */
   function hello_menu(){
        $item['hello/morning'] = array(
            'title' => 'Hello, Good Morning!',
            'description' => 'Greeting Message',
            'page callback' => 'lol',
            'access callback' => TRUE
         );
         return $item;
    }

     /**
      * Provide simply text greeting message
      */
     function lol(){
        return t('Hello, how are you today? We hope you are all right');
     }

3. You have just finished. Now place the two file in a hello folder, then archive it.
4. Open your Drupal administration page, then install the module. Then enable it
5. See in the navigation menu, and try to click it.

No comments:

Post a Comment