ColdBox Multi SIte Architecture

I am trying to create the multiple site using coldbox they will have some code in common and some site specific code. Is there a specific routine (or configuration ) which will allow me to separate shared code and site specific code. What should be shared ? And what should be in client specific and how to differentiate either we calling the shared portion of the code or client specific?

Hi Erik,

I’m running a three CB apps which make use of ColdBox’s “external” conventions for models, views, interceptors, plugins etc. This comes in very handy as I can store all of these files in an external “common” or “shared” folder and each app’s ColdBox.cfc config file can reference in the configure() function. Do a quick search for “external” in Coldbox.cfc and you’ll come up with a list of all the ways you can store things outside of your app to be shared. Hope this helps.


That would be my recommendation. Then you can use inheritance to overwrite any specific pieces of your model or handlers. Works pretty darn slick.

Curt Gratz

Computer Know How

So that means I need to have for each site separate coldbox.cfc?

can you guys give me some examples. What I want to do is: I have I site but I want to reuse most of the code, by simple chnaging the datasource so it looks into separate database, use all model files from the main site but functionality will be the same

What should be shared and what not is up to you.

I have designed and am running here a ColdBox application that currently has 3 domains connected to the application, they all have a different database. But they all have their own configuration if supplied, if not it uses the default one.

All you need to do is think about how you would do it outside of ColdBox as the idea is not different, then you write it in ColdBox with that concept in mind.


Andrew Scott

Here is a trick that will work a better way.

This is provided you have some mechanism to identify and setup the application based on the domain name or something, write an interceptor that uses the afterConfigureLoad() and then just manual change the views/externals etc.

I use this method with great success in one application, and I use the external locations for anything custom that is not apart of the application. So what this means is that the standard conventions are for system and application specific if required, and for any default views UI etc. I then uses the external views to override the system conventions, which means that if the view exists then it uses that to display what you need to display.

Handlers can be done in the same manner, but I have chosen something totally more awesome here. Which allows for something similar to if the handler doesn’t exist then convention is used, or even extends the original handler to provide re-use of code and further customisation if required for that domain.


Andrew Scott



Andrew Scott

In the Application.cfc do a check and whatever you need to identify the database, and then just change the datasource global variable or if you are using ORM change the settings there as well. The trick is how to identify the name of the database from the domain name, but if you really think about this a simple look up on the domain and pull the name of the datasource to use and store it in a global variable, or in the ORM settings if you are using ORM.


Andrew Scott

Can you show me the sample architecture. How can I use external models in site 2 in application.cfc. is the path need to relative path ?