How do I learn to build a module in Drupal

Today I have a project from AppraisalWorld that I need to build a module in Drupal. I have known this Drupal CMS since I learned the Joomla Environment but I didn’t have a chance to build many complex modules. So this is an opportunity for me to learn how to build a complex module for Drupal environment.

First, I go to www.drupal.org and read how Drupal works after I install. Then I watched some videos that teach me why and how to use Drupal. Of course, it’s all about the benefits of using Drupal. And then now comes the fun part. I started downloading some contributed modules that you can find here http://drupal.org/project/modules?page=1. You will find tons of contributed modules for Drupal system.

At first, I expected there’s a .sql file like in Joomla and WordPress systems, so I can load to MySQL DB but I keep searching in all folders, I couldn’t find it. So I know that it maybe generating during the installation of the module. Luckily enough, I found a function that use hook_schema() in the file .install. That’s where the table is created in the database. In this function, you have to define a table name, an array of fields, type, length, not null, and default for each table. If you want to add records to database table, build a function that uses hook_update_n and use query “INSERT INTO”.

Each module has to have at least .info and .module files as a mandatory. The .install, or .inc, or .admin.inc, or .tpl.php are just optional depends on how complex your module is.

In the next blog, I will show you how to start with the .info page to get your module going. Stay in tune.