- Database Tables and Data
- Module Navigation
- Displaying your Pages
- Common Tasks
- Example Modules
This function must be named: my_module__install() (where my_module is the module folder name). It takes a single parameter: the $module_id, passed to it from the core code, in case you need it.
Here's a simple example of how this function is formatted:
The module ID is passed to the function in case you need that information. Otherwise you can just ignore it.
The return value is important. It needs to be an array with two indexes. The first indicates whether the installation was successful or not. If it's set to false, Form Tools will halt the installation. The second parameter is what should be displayed to the user - this is either a success or error message, depending on the first parameter. Note: this second parameter does not need to be included for success messages. By default, a successfully installed module will automatically display a message informing the user of this with a "select this module" link. The second parameter, if included, will override this default message. So to rely on the default message, just pass an empty string as the second parameter, like so:
What your install script DOESN'T need to contain
As mentioned, your custom installation function is called from within the Form Tools core code. That code takes care of a lot of stuff you don't need to know about, including:
- A new record for your module is created in the modules database table
- The module menu is built and stored in the module_menu_items table.