Sorry if this is obvious but I haven't figured it ...
# fw1
r
Sorry if this is obvious but I haven't figured it out. One our subsystem bubbles up to the default layout, in that layout a few views are called. The subsystem complain the views cannot be found, is this a bad design? Should the default layout not have views included? Also, is it possible to call a view from the main app in a subsystem? Thanks!
c
Whether or not a layout should contain views, I think would depend on the situation. Is there conditional logic that determines whether or not the views are loaded/rendered? As for the error about the views not being found - you might need to specify the main subsystem as a prefix to the view name within the layout so that they can be found no matter the context. Could you share a snippet of the layout code where the views are called?
r
Thanks for the replay! The layout is quite basic and works fine when in the main system.
<!--- START BODY CONTAINER --->
<div id="body_container"> <!--- START HEADER CONTAINER ---> <cfinclude template="mod_header.cfm"> #view('fragments/mod_header')# <!--- END HEADER CONTAINER --->
I keep sending premature, my apologies. What is considered the main subsystem? I just introduced the first subsystem, prior we did not use any so everything was at the root of the app. This subsystem view is the first that will use the default layout, and it worked before moving it into a subsystem
c
I think that the
view('fragments/mod_header')
might just need a prefix on the relative path. Try
view('views/fragments/mod_header')
. If that doesn't work, maybe
view('main/views/fragments/mod_header')
?
r
oops that cfinclude is commented out in the real code I accidently removed the comment when pasting
c
Actually, before trying that, can you share what your application folder structure looks like?
r
Sure...
c
so is "fragments" a folder under the main app's "views" folder?
r
Yes
c
OK. Try the suggestions about adding some more path info I sent above.
r
Tried with and without 'main' in the path. no luck
so main is a folder in views, that messing with it maybe?
c
yes, could be. I moved my application to ColdBox some time ago, but I'm going to dig back in and see how I handled this. Give me a few minutes.
👍 1
Try this:
view(':fragments/mod_header')
. The colon prefix tells FW/1 that it needs to look in the main application, not in the current or other subsystem.
1
FYI, you can also load views from other subsystems that way too. So if you are in a
foo
subsystem and want to call a view in the
bar
subsystem, you can do
view('bar:myBarView')
.
r
That was it! Thanks so much!