2010-07-09, 01:54 AM
Today we'll focus on adding a new section in the admincp complete with the sidebars and all
Eg.
Some Assumptions I'm making:
* You have at least a basic understanding in PHP
* You have a html editor (recommend NOTEPAD++)
* FTP access
- First FTP to your mybb root directory
- goto admin/modules folder
- create a new folder name it what you would like to name the new nav tab
We'll use the name "testing".
After the folder is create enter it and create a new file inside called
module_meta.php (name it exactly this).
The file needs 3 functions to work
foldername_meta()
foldername_action_handler()
foldername_admin_permissions()
therefore for us it would read
testing_meta()
testing_action_handler()
testing_admin_permissions()
Functions Defined
Create functions like so (some items defined)
As you can see in the comments
*1 you can change you add the links to the different sections in this case going to the testing module and spam sidemenu section.Anything after "module=testing/" is the url of the submenu
*2 build our "sidemenu"
*3 this actually builds the "tab link". $page->add_menu_item("testing",<--- this testing can be replaced by a lang such as $lang->testing etc
>> the 400 the locationof the tab 10 first 20 second etc 400 means last in the sequence unless we create a new 410 or whatnot
>> "index.php?module=testing" this link has to be consistent
>> Of course you will have to create these pages in the same directory and fill them with content to make them do stuff.
*5 default page. This is the page that will be shown always when you click the tab
formatting these pages and other advanced stuff for some other time
Eg.
Some Assumptions I'm making:
* You have at least a basic understanding in PHP
* You have a html editor (recommend NOTEPAD++)
* FTP access
- First FTP to your mybb root directory
- goto admin/modules folder
- create a new folder name it what you would like to name the new nav tab
We'll use the name "testing".
After the folder is create enter it and create a new file inside called
module_meta.php (name it exactly this).
The file needs 3 functions to work
foldername_meta()
foldername_action_handler()
foldername_admin_permissions()
therefore for us it would read
testing_meta()
testing_action_handler()
testing_admin_permissions()
Functions Defined
Create functions like so (some items defined)
function testing_meta()
{
global $page, $lang, $plugins; //this is added to add language etc
$sub_menu = array(); // start building our side menu bits
$sub_menu['10'] = array("id" => "spam", "title" => $lang->spam, "link" => "index.php?module=testing/spam"); // 1.added first menu item
$sub_menu['20'] = array("id" => "banning", "title" => $lang->banning, "link" => "index.php?module=testing/banning"); //added second menu item
$plugins->run_hooks_by_ref("admin_testing_menu", $sub_menu); //2.
$page->add_menu_item("testing", "testing", "index.php?module=testing", 400, $sub_menu); //3.
return true;
}
As you can see in the comments
*1 you can change you add the links to the different sections in this case going to the testing module and spam sidemenu section.Anything after "module=testing/" is the url of the submenu
*2 build our "sidemenu"
*3 this actually builds the "tab link". $page->add_menu_item("testing",<--- this testing can be replaced by a lang such as $lang->testing etc
>> the 400 the locationof the tab 10 first 20 second etc 400 means last in the sequence unless we create a new 410 or whatnot
>> "index.php?module=testing" this link has to be consistent
function testing_action_handler($action)
{
global $page, $lang, $plugins; // same deal
$page->active_module = "testing"; //make an "active tab" effect that this is the selected module
$actions = array(
'spam' => array('active' => 'spam', 'file' => 'spam.php'), //4.
'banning' => array('active' => 'banning', 'file' => 'banning.php') //4.
);
$plugins->run_hooks_by_ref("admin_testing_action_handler", $actions);
if(isset($actions[$action]))
{
$page->active_action = $actions[$action]['active'];
return $actions[$action]['file'];
}
else
{
$page->active_action = "default"; //5.default page
return "default.php";
}
}
*4 this is where we redirect the sidemenu items to their respective pages>> Of course you will have to create these pages in the same directory and fill them with content to make them do stuff.
*5 default page. This is the page that will be shown always when you click the tab
formatting these pages and other advanced stuff for some other time