RE: [coldbox:17121] Overriding Views/Layouts for a Module

I would check out externals. You can have as many external locations you want. Check out this ColdBox Connection where I showed how to have two ColdBox sites that all inherited base functionality via externals.

http://experts.adobeconnect.com/pzu9rc9pc0/

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Brad,

Thanks for the pointer to the connection session. One question for you … how does this work with modules? The sticking point I see here is if I wanted the module model to be shared, but customize the views/layouts in each site, I think I would have to duplicate or create extended cfc shells in each site. Is that correct or do you have a way to split the model and the views/layouts in a module?

Thanks!

– Jeff

When I looked at this, the answer for me was in the externals. However this is something that you need to consider with this option, as you see my code uses external locations.

So ColdBox needs to be told that you want to use the externals first, as by default if it can’t find anything in the normal conventions it will look in the External conventions. Once you make that change, then the same rule applies to all handlers and views etc, if they don’t exist they should fall back to the normal convention location.

At least that is how I did it.

The idea is simple, when a handler is loaded from an external location, you can then choose to extend from the normal convention to then re-use the code rather than duplicating the code. And the way to do this is get a copy of the renderer plugin and make the changes to do this, and drop it in your applications extensions folder. If that doesn’t exist create it or use the config.cfc to change its location and drop the new renderer in there.

I have never liked the way ColdBox uses the normal conventions over the external conventions, for this very reason. But I am guessing this is what you are also going to have to do.

But if you don’t want to go that route, then you can change the normal conventions instead of the external conventions and treat it that way, which is what most people do. Again the same rules apply, if it can’t find it in the normal convention, it will then check the external convention.

I am sure I blogged about this once before, but I can’t find the article I wrote, but this has been discussed in here a bit over the last 3 years.