Is there any way to change the fw settings? The conventions laid out by the coldbox core in the settings.cfc file can be overwritten in the application employing the coldbox framework, but they are not overwritten in the literal sense of the word.
I need this for my views. I recently moved the views outside of the application root, to make it possible to use some form of theming, where the view files can be changed according to the selected theme.
I know there is a setting called viewsExternalLocation, that I can overwrite in my coldbox.cfc config inside my application. But this setting is only the secondary view it checks. It first checks if the view file is available in the convention location (viewsConvention), whereafter it checks the external location.
I’d want to make this current external location my primary location, so it checks there first, wherafter I want the secondary location of my views to be a default theme (of view files) where the application would check for files not found in my primary location. The secondary location would be on a similar file path.
- server root
- coldbox system files
- default theme
- views- theme 1
- views- theme 2
- views- …
- all application files & folders (handlers, models, …)
Is there any way of achieving this? I am currently unable to change the viewsConvention file @ runtime (I run multiple applications on the same coldbox system folder).
Since that conventions and externalViews config is scoped to the application, changing it directly at runtime would affect the entire application, and it sounds like you are running from one App root so that probably wouldn’t be good. I wouldn’t suggest using those settings to do what you’re trying to do.
You can change the layout at runtime with
setLayout('theme1') and then use that to handle view selection or use the “layout” argument in the setView() function.
My suggestion would be to add a requestContextDecorator in the appropriate place in your “coldbox” config settings struct and then write an overload to the setView(), which handles default view location, according to your conventions, if the selected theme view does not exist.
The only catch might be if you also want to have cascading view setup available in your includes to use with the renderView() function. The renderer can’t be decorated (that I know of) as it’s part of the SuperType. You could add a method to your Request Decorator, which would handle the cascading view conditionals before returning renderView() on the correct path.
I could give this a go. This is not exactly what I was looking for, sounds way too complex for a simple location change, so I will still look around for another way to do this.
But the documentation got me interested enough to try it out.
Thanks for the suggestion!
Can you just swap the views folders you’re using, so you put your “default” views in the external location and the “overrides” in the view convention? I’ve done that before.
ColdBox Platform Evangelist
Ortus Solutions, Corp
ColdBox Platform: http://www.coldbox.org