Thursday, 26 February 2015

How to make a module in drupal


Steps

1) Create a folder in drupal directory

        C:\wamp\www\drupal\sites\all\modules
             --folder name firstmodule

2) Create a two File .info and .module file
          -- Your .info and .module file name same as your folder name

firstmodule.info file Look

name = First Module
description = My First Module In Drupal
core = 7.x


firstmodule.module file Look

        -- create a hook menu in my module file

function Users_menu() {

$items['testing'] = array(
'title' => t('My First Module In Drupal'),
'page callback' => 'testing_module_block_view',
'access callback' => TRUE,
);
        return $items;

}


      -- create a block using hook_block_view

function testing_module_block_view($block_name = '')
{
     -- create a form using drupal_get_form
$form = drupal_get_form('Testing_form');
$block = array
(
'content' => $form,
);
return $block;
}

    -- your custom function 

function Testing_form(){
$Hello = "Hello World";
return $Hello;
}

// My Module its Complete 

-- go and active your module




No comments:

Post a Comment