PHP Bulletin Board Home
News About Home
Features of phpBB Test drive phpBB Downloads Support for phpBB The phpBB Community Styles for customising phpBB 3rd party modifications to phpBB

Support Home | Knowledge Base Home | Submit Article | Search Articles | Browse Articles
 Creating a new Admin Page 
Description: This article explains how to create a new page within the admin panel with links in the left-hand menu pane.
Author: Graham
Date: Wed May 19, 2004 12:24 pm
Type: HowTo
Keywords: admin, menu, MOD
Category: MODifications
In phpBB, the contents of the Admin Control Panel menu is generated dynamically each time it is visited. The admin/ directory is scanned for all files whose name begins "admin_". This file is then include()'ed in the script which builds the menu. In order to appear in the menu (and to avoid errors), the first few lines of the script should be as follows.
Code:
define('IN_PHPBB', 1);

if( !empty($setmodules) )
{
   $filename = basename(__FILE__);
   $module['Section_Name']['Menu_Text'] = $filename;

   return;
}

Where "Section_Name" is the name of the entry in the language pack which should be used as the caption of the section where this page is to be displayed. "Menu_Text" is again the entry in the language pack which should be used as the link to this page.
These values should be defined as language entries within the lang_admin.php file as follows. If no matching language pack entry exists, then the supplied text (minus any underscore characters) will be used, but ideally a language entry should be used to allow for easy translation of your MOD into other languages.
Code:
$lang['Section_Name'] = 'Your Section Name Here';
$lang['Menu_Text'] = 'Your Menu Item Text Here';

If your page can be used for several different actions and you wish it to have multiple entries in the menu, then you can do this by adding extra $module lines as shown below. (Note that the section name for each entry does not need to be the same)
Code:
define('IN_PHPBB', 1);

if( !empty($setmodules) )
{
   $filename = basename(__FILE__);
   $module['Section_Name']['Menu_Text1'] = $filename . "?mode=user";
   $module['Section_Name']['Menu_Text2'] = $filename . "?mode=group";

   return;
}

Following this code which determines the menu location of the page, you should then include the following items at minimum to ensure that all the common admin files are included ready for use in the main body of your page. These entries ensure that only administrators will be able to access your page and that all the common variables are instantiated.
Code:
//
// Load default header
//
$no_page_header = TRUE;
$phpbb_root_path = './../';
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);

Following this, you can code the page as you would any other page within phpBB, with all the usual global variables being available for use.
As a final point to note, you should ensure that all URI's generated by your page to other phpBB pages (or back to itself) are passed through the append_sid() function as a security measure. Failure to do this could lead to your script not performing as expected.


Username: Password:
News | Features | Demo | Downloads | Support | Community | Styles | Mods | Links | Merchandise | About | Home
 © Copyright 2002 The phpBB Group.