Module Routing Hidden Gem

Just wanted to mention a hidden gem that maybe not many people know about.

When you are developing app with modularity in ColdBox, you will come into a place where you need to embed modules within modules. ColdBox 4 introduced this as Module Inception. You can also create URL Routing that behaves this way as well.

For example. Let’s say you have a module called contentbox and within it another module called security, and you want to embed the routing for the embedded module within the contentbox entry point.

contentbox - entry point → /contentbox

  • security - entry point → /contentbox/security

Then in your routes for the contentbox (parent) module you can declare the entry points. yes, you can do more than one.

routes = [
{ pattern = “/security”, moduleRouting = “security” }
]

That’s it. The moduleRouting allows you to tell the routing service to route all URLs to that specific module when using the incoming pattern. So any route that starts with /contentbox/security will be forwarded to the security module for processing.

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057
Direct: (909) 248-3408

ColdBox Platform: http://www.coldbox.org

ContentBox Platform: http://www.gocontentbox.org
Linked In: http://www.linkedin.com/pub/3/731/483

Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano | twitter.com/gocontentbox

It is so intuitive, Luis. I love it. Thank you for sharing the gem!

Regards,
Ryan Hinton