Community management insight at

Bookmark and Share

Adding a New Admin Panel link

Adding a New Admin Panel link

Postby Thoul » October 19th 2003, 2:37 pm

So, you've decided you want a new link in your Admin Panel's navigation frame. But what kind of link do you want to add? If you're looking to add a link below the "Preview Forum" link near the top, there are a couple of hacks you can use for that.

If you want to add a new link under a category, that's a little harder. First you need a file in the phpBB/admin/ directory. Chances are you probably already have one there to which you want the new link to point. This file is going to have to be named admin_something.php. The something can be whatever you want - there are existing files such as admin_board.php and admin_users.php. Your file, when named in this manner, will be included into the navigation frame's page to create the links you see in that frame.

In your file, there should be a line similar to this near the top. We're going to add some new code below that line.

Code: Select all
define('IN_PHPBB', 1);

This is the new code we'll be adding. If you look at the existing admin files, you'll see code similar to this in almost all of them. Go ahead and add this to your new file. Look at your ACP's navigation frame after this change and you'll see a new category, called "Category," containing a link called "Link_Name." The URL for the link will have been set by the variable $filename in the code below.

Code: Select all
if( !empty($setmodules) )
	$filename = basename(__FILE__);
	$module['Category']['Link_Name'] = $filename;


Now, let's customize the link. The $module line lets us do this. As you can see, this line in the above code contains the words Category and Link_Name. If Category is changed to the name of an existing category, then the link will be added under that category. Otherwise, a new category with the name you use will be shown. Changing Link_Name alters the text used for the link, as you may have guessed. Here are some examples.

Code: Select all
// Add link called "My Styles" to existing Styles category
$module['Styles']['My_Styles'] = $filename;

// Add link called "Delete Board" to existing General category
$module['General']['Delete_Board'] = $filename;

// Add link called "Hack Settings" to a new "Hacks" category
$module['Hacks']['Hack_Settings'] = $filename;

Something interesting to note is how you can phpBB's language system to change the name of a category or link based on your selected language. If the values used for Category or Link_Name are also the name of language variables defined lang_admin.php, then those language variables will be used for the category and/or link text. For example, say you've got a language entry in your French lang_admin.php called $lang['Hack_Settings']. The contents of that entry would be the link text for the last link in the above examples.

If there is not a matching entry in the language files, then the category or link text will be exactly as you specify, except for one possible change. Any underscores will be replaced with spaces. Hack_Settings would become Hack Settings, Delete_Board would become Delete Board, and so on.

You can have multiple $module lines in a file. Take a look at this example from the phpBB 2.0.6 admin_styles.php. It adds four different links under the Styles category. Notice how some of these have query strings, such as ?mode=create. These query strings will be part of the URL in the link, allowing us to access different parts of the style management system while keeping it all in one file.

Code: Select all
if( !empty($setmodules) )
	$file = basename(__FILE__);
	$module['Styles']['Add_new'] = "$file?mode=addnew";
	$module['Styles']['Create_new'] = "$file?mode=create";
	$module['Styles']['Manage'] = "$file";
	$module['Styles']['Export'] = "$file?mode=export";

Existing category names you can use in a $module link include Styles, Users, General, Forums and Groups. Many hacks also add new category names in their Admin Panel files.
User avatar
Posts: 18551
Joined: July 30th 2002, 11:30 am
Location: USA

Return to phpBB 2: Customizing Your phpBB

Who is online

Users browsing this forum: No registered users and 0 guests