3.11.2. get_template_file

(Phorum 5 >= 5.2.11)

Allow modules to have influence on the results of the phorum_get_template_file() function. This function translates a page name (e.g. list) into a filename to use as the template source for that page (e.g. /path/to/phorum/templates/emerald/list.tpl).

Call time:

At the start of the phorum_get_template_file() function from common.php.

Hook input:

An array containing two elements:

Hook output:

Same as input. Modules can override either or both of the array elements. When the "source" element is set after running the hook, then the file named in this element is directly used as the template source. It must end in either ".php" or ".tpl" to be accepted as a template source. Phorum does not do any additional checking on this source file name. It is the module's duty to provide a correct source file name.
Otherwise, the template source file is determined based on the value of the "page" element, following the standard Phorum template resolving rules.

Example code:

function phorum_mod_foo_get_template_file($data)
{
    // Override the index template with a custom template
    // from the "foo" module.
    if ($data['page'] == 'index_new') {
        $data['page'] = 'foo::index_new';
    }

    // Point the "pm" template directly at a custom PHP script.
    if ($data['page'] == 'pm') {
        $data['source'] = './mods/foo/pm_output_handler.php';
    }

    return $data;
}