Now i explain the simple and easy steps to create a first drupal module. Our first module will show simple text, format it, and display it as a block in the site’s layout. There are two important files that every module must have.
The first is .info file, and the second file is .module (dot-module) file, which is a PHP script file.
1) Creating the .info and .module files
2) Creating a new module
3) Using basic hooks
4) Installing and configuring the module
Go to the root directory –> sites –> all –> modules.
Create a folder name helloworld
1 2 3 4 5 | ;$Id$ name = "Hello World!" description = "Your first drupal module" core = 7.x php = 5.3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?php // $Id$ * @file * Simple module to showing hello world */ /** * Implementation of hook_block() */ function helloword_block($op='list' , $delta=0, $edit=array()) { switch ($op) { case 'list': $blocks[0]['info'] = t('Hello World!'); return $blocks; case 'view': $blocks['subject'] = t('Hello World!'); $blocks['content'] = t('This is your first drupal module!'); return $blocks; } } ?> |
Step #1: Enabling The Module
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: Drupal, drupal 8 modules, drupal 8 modules tutorials, drupal module, drupal module filter, drupalmodules, how to create drupal module, modules in drupal