[ColdBox 3.6.0] Custom layout per user

I want make my app personalizable. Each user can upload a layout file and change the appearence of the app. The folder is external to the application.

How can I set the layout external locations and the load the right template for each user?

The easiest way would be to do something like this in one of your interceptors.

public void function preProcess(event, interceptData) {


And you would just put the code you need in here, to pull up which layout the user is using.

I should have added, that in your handler you will need to do something like this as well.


Another way you could do this, so that you don’t have to change the views, would be to look into the requestContextDecorator and make the change and extend the original. Or you could even write an AOP to maybe do the work for you on handlers.

If I run a preProcess event, the layout should be setted before I can try to access to user data.

I should before grab the userId from session or database and then setting the proper layout. So probably it would be better a SessionStart or preEvent or maybe setting a custom interception points.

I have not much feeling with interceptors and don’t know wich point suits well in this case…

I used that as an example to get you thinking, as for getting the user data? Are you holding all this information in the session? A quick DB call to grab what you need, is cheaper than holding it all in session.

I don’t think there is any real savings whether it be preProcess or preEvent, as they are both run in the work flow regardless.

If your users are uploading .cfm files, that seems like a potential security issue plus a chance for users to introduce bugs. Do you trust your users and are they competent enough to develop a ColdBox Layout?



ColdBox Platform Evangelist
Ortus Solutions, Corp

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