tl;dr: renderLayout(layout="myLayout", view="alpha/bravo/viewFile")
resolves alpha
as a module name rather than a package name in the host application, even if code execution is in the package rather than the module.
How do I get the path resolution to be consistent when either running the handler directly or when calling it via runEvent
from a module?
I posted this on the CB google group, but then thought it may be best to ask here.
Working example here: https://github.com/jinglesthula/cbModuleExample
If you run install (I .gitignored the coldbox folder), then cd
into the /app
folder and server start --rewritesEnable
you can visit http://127.0.0.1:<whatever port>/example/admin/test/ajax
to see it in action.
From the example:
/app/modules_app/example/handlers/admin/test.cfc -> ajax()
calls runEvent("admin.test.ajax")
/app/handlers/admin/test.cfc -> ajax()
calls `renderLayout( layout = "layout.div", view = "admin/test/ajax" )
"admin/test/ajax"
normally resolves to /app/views/admin/test/ajax.cfm
, but in this case it's resolving to /app/modules_app/admin/views/test/ajax.cfm
.
You can comment out line 18 and uncomment line 19 in /modules_app/example/admin/handlers/test.cfc
to see a workaround.
You can also go to /admin/test/ajaxDirect
in your browser to see that the renderLayout()
call in the non-working example is correct.
Note: I have this.viewParentLookup = true
in my ModuleConfig.cfc. I've tried reloading the module with it set to false and I get the same result.