[Coldbox 4.1.0] Views location for modules

We have a handler that inherits from a module’s handler. Is there any way to set it up so that the handler will find the view automatically in the module’s folder?

Here’s handler.cfc:
component extends=“testModule.handlers.testModuleHandler” {
public void function index(any event) {

}

}

The view is located in /modules/testModule/views/testModuleHandler/index.cfm.

At the moment we need to add this line to the “index” function to make it work:
event.setView(view=“testModuleHandler/index”, module=“testModule”);

How can we avoid having to add that line, and have CB automatically find the view in the module folder the same way it’s doing it for “external views”.

Thanks for any help.

Where is this handler? In the same module?

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057

The handler.cfc is outside of the module (part of the host application), but it’s inheriting a handler from the module.

Any reason why you are using inheritance from a module? What is the taxonomy?

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057

We’re doing this for two reasons:

  1. Inheritance allows for more liberty for customization. Should we try to use settings instead for customization?
  2. We don’t really like the url format to access a module action, so instead of “http://testsite.com/?event=mod:dashboard”, we prefer “http://testsite.com/?event=dashboard”.

Just a note on the URL-- if you use SES urls, you can have full control over what the routes are.

To answer your original question-- no, the handler’s super class has no bearing on where views are looked for. You could probably make the “module” parameter a variable that’s paramed in your super’s “preHandler” or something.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

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

I had the same problem by creating a new module with commendbox 3.3. The new custom module went into the folder “/modules_app” which is fine regarding the blog post

https://www.ortussolutions.com/blog/contentbox-extending-contentbox-3-with-your-own-custom-modules.

  • which makes sense to me. Even if it covers content box

But than I got the same error as Nick.

Not sure if this if “/modules_app” is the “new default” place for custom modules in any CB app. To avoid the error I had to move it to the “/modules” folder

Daniel

The new modules_app convention is a 4.3 feature

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057

Thanks Brad. We’ll look into the preHandler suggestion.