Module file
If you're not adding a full file, skip this part
The filename should be the module class (e.g. acp), an underscore ('_'), the module name and the extension (usually .php). Example: acp_foobar.php. The file should be placed in includes/{MODULECLASS}, {MODULECLASS} being acp, mcp or ucp
The file should have the usually used file header:
- Code: Select all
/**
*
* @package {PACKAGENAME}
* @version $Id: $
* @copyright (c) 2008 {COPYRIGHT_HOLDER}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
{PACKAGENAME}: Either acp, mcp or ucp.
{COPYRIGHT_HOLDER}: You. Duh!
then, the class (with docblock):
- Code: Select all
/**
* @package {PACKAGENAME}
*/
class {CLASSNAME}
{
var $u_action;
var $tpl_path;
var $page_title;
function main($id, $mode)
{
}
}
{CLASSNAME}: Same as filename, without extension. Example: acp_foobar.
Properties
$u_action: Path to current module, including session id. This property is set automatically. Example: ./index.php?i=foobar&sid={SESSION_ID}&mode=bar
$tpl_path: Template file's filename, without extension. Should be set in the module. Example: acp_foobar
$page_title: Page title, should be set in the module.
$module_path: Path to module files. Set automatically. Example: ./includes/acp
Info file
If you are adding a full file, you'll need to make your own info file too. If you are adding mode, you'll need to edit the existing info file. The info file should be placed in the includes/{MODULECLASS}/info folder, and have the same filename as the module file. Example: includes/acp/info/acp_foobar.php.
The file header is the same as the module's file. The class should look like this:
- Code: Select all
/**
* @package {PACKAGENAME}
*/
class mcp_foobar_info
{
function module()
{
return array(
'filename' => 'mcp_foobar', // The module's filename
'title' => 'MCP_FOOBAR', // The title (language string)
'version' => '1.0.0', // The module's version
'modes' => array( // This is where you add the mode(s)
'foo' => array('title' => 'MCP_FOOBAR_FOO', 'auth' => 'acl_m_foo', 'cat' => array('MCP_FOOBAR')), // Mode is 'foo', title is $user->lang['MCP_FOOBAR_FOO'], the permission needed is 'acl_m_foo'; category's language string is MCP_FOOBAR
'bar' => array('title' => 'MCP_FOOBAR_BAR', 'auth' => 'acl_m_bar,$id', 'cat' => array('MCP_FOOBAR')), // The permission needed is 'acl_m_bar' on the current forum id ($id)
),
);
}
function install()
{
}
function uninstall()
{
}
}
Adding a module category
I'll use the ACP as an example
Go to ACP -> System -> Module management -> Administration Control Panel
This brings you to the (top-level) categories of the ACP. To add a new top-level category, type the new category's name or language string in the input field in the bottom left of the page and click Create new module.
In the options screen for your new category, be sure to select Type: Category, Parent: No Parent (or a parent category if you want to), Module enabled: Yes
The new category will not display until there are active modules in it.
Adding a module
I'll use the UCP as an example
Go to ACP -> System -> Module management -> User Control Panel
This brings you to the categories of the UCP. Click on the category where you want to add your module. Now type the name or language string in the input field.
Select Module type: Module; Module enabled: Yes; Module displayed: Yes. Now select a module from the drop down menu on the lower right-hand side of the screen. This drop down menu includes all info files located within the /includes/ucp/info/ directory.
Click submit, done!