MyBB Community Forums

Full Version: Admin Config Page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to make my plugin add a new page to the Admin CP. So far i've gotten a link in the menu (with a hook to admin_config_menu), but when i click it nothing happens (well i get taken to the Home config page).

How do i add a page so it functions properly and has everything for it to work?

Also, what's a breadcrumb?
I've been meaning to write a tutorial on ACP modules, but it's pretty simple.

Basically, you create a directory in /admin/modules/. If I wanted to make a module for... Pet Dog Management or something I would choose /admin/modules/petdog/ or whatever.

Inside that directory you need at least two files: module_meta.php and a page file. module_meta.php tells the ACP what links it should put in the sidebar and includes the action handler which directs the ACP to your page.

I suggest reading through the other modules code to get a feel for how things are done. It's confusing at first, but becomes very simple quickly.
Umm okay, but what if i just wanted a new page under an existing module?
Like i want my page to be in the config module.

I've been reading through the Help Center plugin, and they use the tools module (like the link is on the Tools & Maintenance page) and don't need a new file or a new directory.

From what i understand, the stuff that's inside the Help Center file is declared in a function called helpcenter_admin or something and it's just called after admin_load
(2011-02-20, 01:22 AM)Steven Wrote: [ -> ]I've been meaning to write a tutorial on ACP modules, but it's pretty simple.

Please do, there's pretty much no documentation at all for adding pages to the usercp or admincp, aside from the hook list in the wiki and looking at other plugins, which is super frustrating.
Add in the install function:
	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets("usercp_nav_misc", '#</tbody>#', '	<tr><td class="trow1 smalltext"><a href="usercp.php?action=ACTION">LINKER</a></td></tbody>');

That will add the link to the UCP nav menu, then define this hook:
$plugins->add_hook("usercp_start", "pluginname_function");

Next, add this function and do your stuff:
// Add a page to the User Control Panel
function pluginname_function()
{
	global $mybb, $templates;

	if($mybb->input['action'] == "ACTION")
	{
		// Do the shizzle for your page here
	
		eval("\$pplist = \"".$templates->get("pproducts_list")."\";");
		output_page($pplist);
	}
}

Dunno if it's the right way to do it, but it works. Also sorry for derailing, OP.
Nvm, so i made the meta file and everything, but how do i get the file to appear in the top menu?
(2011-02-20, 02:59 AM)Scoutie44 Wrote: [ -> ]Dunno if it's the right way to do it, but it works. Also sorry for derailing, OP.

Whoa, why are you altering templates? There are other ways to add them just by hooking.
Who cares? If you start doing modifications on the fly, you're only going to make it difficult to the end user. What if they want to modify the template for several different themes?
Any updates on the Wiki insert on this subject ?