Adding Admin Menus to your Module
To add Menu Items for your Admin Modules into the Admin Interface, you need to update the onLoad and onUnload functions of your ModuleConfig.cfc file.
In this example, you'll start by adding the Menu Item by updating onLoad:
1
* Fired when the module is registered and activated.
2
*/
3
function onLoad(){
4
// Let's add ourselves to the main menu in the Modules section
5
var menuService = controller.getWireBox().getInstance( "[email protected]" );
6
// Add Menu Contribution
7
menuService.addSubMenu(topMenu=menuService.MODULES,name="mySecrets",label="my Secrets",href="#menuService.buildModuleLink('mySecrets','home')#" );
8
}
Copied!
Next, you'll update the onUnload function to remove the Menu Item when deactivating our Admin Module:
1
* Fired when the module is unregistered and unloaded
2
*/
3
function onUnload(){
4
// Let's remove ourselves to the main menu in the Modules section
5
var menuService = controller.getWireBox().getInstance( "[email protected]" );
6
// Remove Menu Contribution
7
menuService.removeSubMenu(topMenu=menuService.MODULES,name="mySecrets" );
8
}
Copied!
Now reload the app (?fwreinit=1). If you activate the mySecrets Admin Module, you should see mySecrets appear in the Modules sub menu items.
Now that your module menu button is working in the admin, you need to add some metadata to your module.
Copy link
Edit on GitHub