Author: Lamonte Harris ( http://cleanscript.com )
Website: Clean Script - Budget PHP & MySQL Freelancing
Mybb Ver: 1.4.2
What: Learn how to get started with creating custom admin modules.
Skills Needed: Basic understanding of PHP and MyBB Plugin system
Alright, after few references from the staff here at myBB Community I would like to take the time and write a short tutorial for you guys who want to add "custom" pages on your dashboard (home module). ( Note this should work on other module pages such as ( Configuration, Forums & Posts, Users & Groups, Templates & Style, Tools & Maintenance ) you get the idea ).
For testing purposes just "copy" the "credits.php" file in "admin\modules\home" folder and rename it to "testmod.php".
Next create a plugin file with the following.
Now that we have the code correct I'll explain what we are doing here.
First off we create our plugin author information.
Next we add our hook to the "admin_home_action_handler" this hook allows us to modify what pages can be displayed on the home module. By default MyBB setup "rules" so that you can access certain pages by default on first install. They also enabled us to modify them rules when ever we want. If your wondering what rules I am speaking of heres a glance:
Line: 40-56 ( MyBB 1.4.2 )
File: admin\modules\home\module_meta.php
Each "module_meta.php" file in each module has these definitions, so you remember at the beginning when I said you could do this on about every module? Well thats basically what I meant.
Now in order to access that module we just created point your browser to:
In conclusion I like this way better when creating modules because it separates my files up in a clean and organized fashion.
Website: Clean Script - Budget PHP & MySQL Freelancing
Mybb Ver: 1.4.2
What: Learn how to get started with creating custom admin modules.
Skills Needed: Basic understanding of PHP and MyBB Plugin system
Alright, after few references from the staff here at myBB Community I would like to take the time and write a short tutorial for you guys who want to add "custom" pages on your dashboard (home module). ( Note this should work on other module pages such as ( Configuration, Forums & Posts, Users & Groups, Templates & Style, Tools & Maintenance ) you get the idea ).
For testing purposes just "copy" the "credits.php" file in "admin\modules\home" folder and rename it to "testmod.php".
Next create a plugin file with the following.
<?php
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
function clanadmin_info() {
return array(
'name' => "Clan Application Management",
'description' => "Handle Clan Applications sent by registered users",
'website' => "http://cleanscript.com",
'author' => "Lamonte Harris",
'authorsite' => "http://cleanscript.com",
'version' => '0.0.1',
);
}
$plugins->add_hook("admin_home_action_handler", "clanadmin_home_action");
function clanadmin_home_action( $actions )
{
$actions['clanapp'] = array('active' => 'dashboard', 'file' => 'testmod.php');
}
?>
Now that we have the code correct I'll explain what we are doing here.
First off we create our plugin author information.
Next we add our hook to the "admin_home_action_handler" this hook allows us to modify what pages can be displayed on the home module. By default MyBB setup "rules" so that you can access certain pages by default on first install. They also enabled us to modify them rules when ever we want. If your wondering what rules I am speaking of heres a glance:
Line: 40-56 ( MyBB 1.4.2 )
File: admin\modules\home\module_meta.php
$actions = array(
'preferences' => array('active' => 'preferences', 'file' => 'preferences.php'),
'credits' => array('active' => 'credits', 'file' => 'credits.php'),
'version_check' => array('active' => 'version_check', 'file' => 'version_check.php'),
'dashboard' => array('active' => 'dashboard', 'file' => 'index.php')
);
if(!isset($actions[$action]))
{
$page->active_action = "dashboard";
}
else
{
$page->active_action = $actions[$action]['active'];
}
$plugins->run_hooks_by_ref("admin_home_action_handler", $actions);
Each "module_meta.php" file in each module has these definitions, so you remember at the beginning when I said you could do this on about every module? Well thats basically what I meant.
Now in order to access that module we just created point your browser to:
admin/index.php?module=home/testmod
In conclusion I like this way better when creating modules because it separates my files up in a clean and organized fashion.