PHP

Tuesday, June 11, 2013

Drupal 7 Module Install file

While creating a new Drupal 7 module, sometimes we need to interact with database. Moreover, we need to create our own table for the module we are creating. This can be achieved using a .install file. We can create  tables for modules manually using MySQL GUI tools, but if we want to make our module install able in any Drupal 7 intallation server then we should create a .install file.
Below are the steps on how to create a .install file:

  1. Open a text editor, i prefer Notepad++.
  2. Create a new file.
  3. Add your install code in the file, sample code is shown in the screenshot below.
  4. Place the file in the module directory, See here on how to create a simple module.
Now when you install the module form admin module section your table will be automatically created in the database.

No comments:

Post a Comment