N2F Yverdon: The mod.ext.php File
One of the new features introduced with v0.2 is the mod.ext.php feature. This feature was a request from a few users and can be a useful way to add functionality to your system.
The premise behind mod.ext.php is similar to that of the sys.ext.php file. However, instead of being included globally, the mod.ext.php file is only included when a specific module is brought into scope. This is particularly helpful if you have large/complicated modules and need some classes or global information that is only necessary when that module is in use.
As an example, let’s pretend that we have a set of classes that are particularly large. We only need these classes inside of our documentation module, so we use a mod.ext.php file to make that possible. Our mod.ext.php is saved in the module directory at ~/modules/documentation/mod.ext.php, just like a sys.ext.php file. The code in the file might look like this:
<?php
require('cls/docmgr.cls.php');
require('dat/docs.dat.php');
?>
Just as with the sys.ext.php files we don’t have to do anything special to use mod.ext.php. Once you create one and the module is called, it will be automatically called into scope before the module’s code is executed.
- Andrew