Prev |  | Next

#### 2.3.3.3. Multiple file modules

These modules are useful in case you need additional files to be stored with your module, for example a settings screen, language files or custom images.

They are stored in their own subdirectory below the directory `{phorum dir}/mods/`. If you have a module named "foo", you will have to create a directory `{phorum dir}/mods/foo/` for storing all module files.

Inside this subdirectory, you will have to create a least two files:

- A file called `info.txt`. This file contains the module information for your module (see Section 2.3.2, “Module information”).
- The PHP file which contains the hook function definitions for your module. The basename of this file should be the same as the name of the module subdirectory. So for our example module "foo", you will have to create a file named `foo.php`.

Using the example module info from Example 2.1, “Module information”, the complete multiple file module would look like this (see XXX why we use the check on PHORUM at the start of the PHP file):

Example 2.3. Multi file module

    {phorum dir}/mods/foo/info.txt
    title: Foo
    desc: This is the Foo module for Phorum. Nothing exciting...
    version: 1.0.2
    release_date: Jan 1st, 2008
    url: http://www.phorum.org
    author: John Doe <johndoe@example.com>
    require_version: 5.2.2
    category: user_features

    hook: some_hook|phorum_mod_foo_some_hook
    hook: some_other_hook|phorum_mod_foo_some_other_hook
    hook: yet_another_hook|phorum_mod_foo_some_other_hook

    priority: run some_hook before some_other_module

    {phorum dir}/mods/foo/foo.php
    <?php

    if(!defined("PHORUM")) return;

    function phorum_mod_foo_some_hook ($data) {
        // Do stuff for "some_hook".
        return $data;
    }

    function phorum_mod_foo_some_other_hook ($data) {
        // Do stuff for "some_other_hook" and "yet_another_hook".
        return $data;
    }

    ?>

So far, the module has exactly same functionality as the single file module from Section 2.3.3.2, “Single file modules”. From here on, the functionality can be extended. Some of the possibilities are:

- Adding custom files to your module tree (images, classes, libs, etc.);
- Letting your module support multiple languages;
- Implementing a settings screen for your module;
- Adding template files for your module; (See XXX about module template files)

Prev | Up | Next
| Home |