This plugin allows multiple modules under a single wheels application.
A module is a group of models, controllers and views stored under a single folder per module. The main benefit is each module can be made self-contained (with models, controllers, views, javascripts, etc..) and can be deployed independently from other modules.
In /config/app.cfm:
<cfscript> this.name = "MultiModuleExample"; this.mappings["/controllers"] = getDirectoryFromPath(getBaseTemplatePath()) & "controllers"; this.mappings["/models"] = getDirectoryFromPath(getBaseTemplatePath()) & "models"; </cfscript>In your /modules/module1/controllers/Say.cfc:
<cfcomponent extends="controllers.Controller"> <cffunction name="hello"></cffunction> </cfcomponent>In your /modules/module1/views/say/hello.cfm:
<h1>Hello World!</h1>
This URL will access the module (for example if you use Railo Express):
http://localhost:8888/index.cfm/say/hello
Namespace works only with controllers and views. Those controllers still can access any models from any modules, regardless of there is a namespace in the URL or not.
In /config/routes.cfm:
<cfscript> addRoute( name="moduleRoute", pattern="/m/[module]/[controller]/[action]/[key].[format]" ); addRoute( name="moduleRoute", pattern="/m/[module]/[controller]/[action]" ); </cfscript>
VERY USEFUL! Set module param by prepending the module name and a tilde(~) to the route name. ie:
In /config/routes.cfm:
<cfscript> addRoute( name="public~PageRoute", pattern="/p/[id]", controller="pages", action="page" ); </cfscript>
This URL will access the namespaced module:
http://localhost:8888/index.cfm/m/module1/say/hello
This will make the plugin check the [module]'s controllers, models, views, etc first, and if something is not found it will fall back to checking other module folders. If you don't want the plugin to check other modules when [module] is specified then add in /config/settings.cfm:
<cfset set(multiModuleCheckAllModules=false)>