MyBB Community Forums

Full Version: Admin Module
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.
I am just starting to look at MyBB and was having a go at making a plugin.
Is there a template anywhere for how to get started with an Admin Module page?
Thanks
Hi,

There's no real basic template, but I can show you some example code which is used to add a full new module to the ACP which will show up in the bar at the top of the page.

The first step is to create a folder in "admin/modules" (the folder name should be unique and not include any spaces and only include standard letters allowed in a PHP function name) and to add a "module_meta.php" file that describes the module: https://github.com/MyBBStuff/SimpleLikes...e_meta.php

Note that there are some key functions you need to implement: "[NAME]_meta()","[NAME]_action_handler()" and "[NAME]_admin_permissions()" (where [NAME] is the name of the folder you created to put the "module_meta.php" inside).

Hopefully that makes sense. The example module I linked above is very simple and doesn't do very much at all.
Hi Euan, Thanks for that!
Do you have any examples of code for just a file placed in inc/plugins?
Ive got install, uninstall, activate and deactivate all working for a database addition and have a link in ACP/Config page but I am not sure how to set up a page for it?
Thanks
(2018-03-25, 07:56 PM)mark36ph Wrote: [ -> ]Hi Euan, Thanks for that!
Do you have any examples of code for just a file placed in inc/plugins?
Ive got install, uninstall, activate and deactivate all working for a database addition and have a link in ACP/Config page but I am not sure how to set up a page for it?
Thanks

Hi,

If you just want a single page in the config module, the easiest way is to simply add a new PHP file into "admin/modules/config/[NAME].php". A fairly short example of one of these files would be: https://github.com/mybb/mybb/blob/featur...endars.php

Your link would then be "admin/index.php?module=config-[NAME]" and you can add the link to the side menu by using the "admin_config_menu" plugin hook: https://github.com/mybb/mybb/blob/featur...ta.php#L44 - you would also need to hook into "admin_config_action_handler" to set the file to "[NAME].php". I actually have some examples of this too:

- Adding a link to the config sidebar: https://github.com/MyBBStuff/MyAlerts/bl....php#L1632
- Handling the link in the admin sidebar: https://github.com/MyBBStuff/MyAlerts/bl....php#L1648
- Adding permissions for the link in the admin sidebar: https://github.com/MyBBStuff/MyAlerts/bl....php#L1660