LogoLogo
SourceSupportTraining
v6.x
v6.x
  • Introduction
    • Contributing Guide
    • Release History
      • 6.1.0
      • 6.0.5
      • 6.0.4
      • 6.0.3
      • 6.0.0
      • Upgrading From v5.x
    • About This Book
      • Author
  • Getting Started
    • Installation
      • System Requirements
      • *CommandBox Installation
      • Source Installation
      • Existing ColdBox Application
      • Docker
    • Updates
  • Usage
    • Using ContentBox
      • The ContentBox Dashboard
        • Home
        • About
      • Content
        • Publish Content
          • Blog
          • Sitemap
          • Content Editing Tips
            • Editor Features
            • Dynamic Variable Output
            • Markdown Support
            • Relocations
            • Scheduled Content
        • Custom Content
          • Content Store
          • Content Templates
          • 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 GitHub
Export as PDF
  1. Back End Development
  2. Back End Development
  3. Modules

Scaffold a Module

If you are planning to build a module, a great way to get started is Scaffolding a Module using CommandBox. CommandBox has a lot of commands and the one we will be using in this case is the ColdBox command. The ColdBox command inside of CommandBox allows you to do a lot of things, including coldbox create for all of these items:

  • view

  • app-wizard

  • orm-virtual-service

  • unit

  • integration-test

  • interceptor-test

  • orm-entity

  • orm-service

  • app

  • interceptor

  • orm-event-handler

  • model

  • layout

  • handler

  • bdd

  • module

  • orm-crud

  • model-test

  • controller

We are of course interested in creating a module. Lets look at that command

coldbox create module

The params for this command are the following:

name=            
author=          
authorURL=       
description=     
version=
modelNamespace=  
dependencies=    
directory=       
script=          

There is also a flag for script: --script

Lets create a module with the command, and see what it produces. Note: Be in the root of your app so the command knows where to put the files. If you are in a subfolder, the command might get lost.

coldbox create module name=customModule2 author="Gavin Pickin" authorURL="http://www.gpickin.com" description="Custom Module 2" version="1.2.3" cfmapping="customModule2Mapping" modelNamespace="customModuleName" directory="modules_app" script=true

Looking at the arguments in more detail

  • name=customModule2

  • author="Gavin Pickin"

  • description="Custom Module 2"

  • version="1.2.3"

  • cfmapping="customModule2Mapping"

  • modelNamespace="customModuleName"

  • directory="modules_app"

  • script=true

The command outputs this:

Created C:\www\wwwplayground\modules_app\customModule2
Created C:\www\wwwplayground\modules_app\customModule2\handlers
Created C:\www\wwwplayground\modules_app\customModule2\handlers\Home.cfc
Created C:\www\wwwplayground\modules_app\customModule2\models
Created C:\www\wwwplayground\modules_app\customModule2\models\models_here.txt
Created C:\www\wwwplayground\modules_app\customModule2\ModuleConfig.cfc
Created C:\www\wwwplayground\modules_app\customModule2\views
Created C:\www\wwwplayground\modules_app\customModule2\views\home
Created C:\www\wwwplayground\modules_app\customModule2\views\home\index.cfm

Here is a visual display of the directory structure

The command creates a Module Config file with all your information. It creates a default handler, called Home.cfc in the handlers folder. It creates a models folder, with just a placeholder file. It also creates a views folder, with the home folder to match the handler, and creates a default index.cfm view.

It is a great way to get started. You can use many of the other ColdBox commands to create additional handlers, views, and layouts. The next time you want to create a module, instead of remembering the conventions, and what files you need, scaffold it with CommandBox's ColdBox create command.

ColdBox modules all work with ContentBox, so what will you create?

Last updated 2 years ago

Was this helpful?

authorURL=""

http://www.gpickin.com
Module Created by CommandBox Scaffolding