LogoLogo
SourceSupportTraining
v5.x
v5.x
  • Introduction
  • Intro
    • Release History
      • What's New With 5.3.0
      • What's New With 5.2.0
      • What's New With 5.1.0
      • What's new With 5.0.0
      • Upgrading From v4.x
    • About This Book
      • Author
  • Getting Started
    • Installation
      • System Requirements
      • CommandBox Installation
      • Source Installation
      • Express Installation
      • Existing ColdBox Application
      • Docker
    • Updates
    • Quick Guide
  • Usage
    • Using ContentBox
      • The ContentBox Dashboard
        • Home
        • About
      • Categories
      • Content
        • Publish Content
          • Blog
          • Sitemap
          • Content Editing Tips
            • Editor Features
            • Dynamic Variable Output
            • Markdown Support
            • Scheduled Content
        • Consume Content
          • Content Store
          • Categories
          • Media Manager
          • Menu Manager
      • Comments
        • Inbox
        • Settings
      • Look & Feel
        • Active Theme
        • Global HTML
        • Themes
        • Widgets
          • Inserting a Simple Widget
      • Media Manager
      • Modules
        • Installing Modules
        • Managing Modules
      • Users
        • Manage
        • Permissions
        • Roles
      • Tools
        • Import
        • Export
        • Static Site Generation
      • System
        • Auth Logs
        • Geek Settings
        • Settings
          • Site Options
          • Admin Options
          • Security Options
          • Login Options
          • Content Options
          • Editor Options
          • Media Manager Options
          • Gravatars
          • Notifications
          • Mail Server
          • Search Options
          • Login Options
        • Security Rules
        • Updates
      • Widgets
        • An Easy Example
        • Inside the Page Editor
    • Developing For ContentBox
  • Front End Development
    • Front End Development
      • File Structure
      • JS and CSS Assets
      • Customizing Views
      • Customizing Layouts
      • Customizing Navigation
      • Global Variables
      • Managing Assets
      • Template Variables
      • The Content Store
    • Theme Development
      • Theme Settings
      • Theme UDFs
      • Theme Templates
      • Theme Layouts
      • Theme Views
      • Theme SEO Functionality
  • Back End Development
    • Back End Development
      • Overriding ContentBox Settings
      • Modules
        • Installing a Module
        • Using a Module
        • Module Locations and Conventions
        • Build a Module
        • Scaffold a Module
        • Theme your Module
        • Build an Admin Module
        • Adding Admin Menus to your Module
        • Adding Meta to your Modules
      • Widgets
        • Core Widgets
        • Simple Widget
        • Widgets with Arguments
        • Multiple Render Function Widgets
      • Interceptors
      • Accessing Logged in User
      • Customizing the Admin
      • Staying on the Upgrade Path
Powered by GitBook
On this page

Was this helpful?

Edit on Git
Export as PDF
  1. Back End Development
  2. Back End Development
  3. Modules

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:

* Fired when the module is registered and activated.
*/
function onLoad(){
    // Let's add ourselves to the main menu in the Modules section
    var menuService = controller.getWireBox().getInstance( "AdminMenuService@contentbox" );
    // Add Menu Contribution
    menuService.addSubMenu(topMenu=menuService.MODULES,name="mySecrets",label="my Secrets",href="#menuService.buildModuleLink('mySecrets','home')#" );
}

Next, you'll update the onUnload function to remove the Menu Item when deactivating our Admin Module:

* Fired when the module is unregistered and unloaded
*/
function onUnload(){
    // Let's remove ourselves to the main menu in the Modules section
    var menuService = controller.getWireBox().getInstance( "AdminMenuService@contentbox" );
    // Remove Menu Contribution
    menuService.removeSubMenu(topMenu=menuService.MODULES,name="mySecrets" );
}

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.

Last updated 2 years ago

Was this helpful?