MyBB Community Forums

Full Version: Admin module page not showing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am working on a plugin that grants the user an award randomly based on a percent. I want the admin to be able to add as many random award entries as he wants. I have done all of this but the problem is that I can't get the admin module page to display.

I've added a new menu item to config module in the ACP and whenever I click the menu item it just redirects me to index.php?module=config.

In my plugin file I have this:
if(defined('IN_ADMINCP')) {
 $plugins->add_hook('admin_config_menu', 'randomaward_admin_submenu');
 $plugins->add_hook('admin_config_action_handler', 'randomaward_admin_action_handler');
} else {
 $plugins->add_hook("newreply_do_newreply_end", "randomaward");
}

function randomaward_admin_submenu(&$args) {
    $args[] = array(
		"id" => "randomaward",
		"title" => "Random Awards",
		"link" => "index.php?module=config-randomawards"
    );
}

function randomaward_admin_action_handler(&$args) {
    $args['randomaward_vars'] = array(
		"active" => "randomaward",
		"file" => "rndaward.php"
    );
}

The file rndaward.php is located in admin/modules/config but it doesn't seem to work, I have tried doing some random stuff inside the rndaward.php and even copying some other module file from a different plugin but the page still won't display, it just stays on index.php?module=config

Here is a demo of what is happening: https://i.gyazo.com/5fb2a9270d0abdb192b1...862c71.mp4

Anyone know what's up?
You need to follow this pattern. Obviously replacing 'mykey' with your plugin's key:

/**
 * @param  array items on the config tab
 * @return void
 */
$plugins->add_hook('admin_config_action_handler', 'my_admin_config_action_handler');
function my_admin_config_action_handler(&$action)
{
	$action['mykey'] = array('active' => 'mykey');
}

/**
 * add an entry to the ACP Config page menu
 *
 * @param  array menu
 * @return void
 */
$plugins->add_hook('admin_config_menu', 'my_admin_config_menu');
function my_admin_config_menu(&$sub_menu)
{
	end($sub_menu);
	$key = (key($sub_menu)) + 10;
	$sub_menu[$key] = array(
		'id' => 'mykey',
		'title' => 'My Title',
		'link' => 'index.php?module=config-mykey'
	);
}
(2018-10-21, 08:14 PM)Wildcard Wrote: [ -> ]You need to follow this pattern. Obviously replacing 'mykey' with your plugin's key:

/**
 * @param  array items on the config tab
 * @return void
 */
$plugins->add_hook('admin_config_action_handler', 'my_admin_config_action_handler');
function my_admin_config_action_handler(&$action)
{
	$action['mykey'] = array('active' => 'mykey');
}

/**
 * add an entry to the ACP Config page menu
 *
 * @param  array menu
 * @return void
 */
$plugins->add_hook('admin_config_menu', 'my_admin_config_menu');
function my_admin_config_menu(&$sub_menu)
{
	end($sub_menu);
	$key = (key($sub_menu)) + 10;
	$sub_menu[$key] = array(
		'id' => 'mykey',
		'title' => 'My Title',
		'link' => 'index.php?module=config-mykey'
	);
}

This did the trick, thank you!
Cool