My understanding/thinking is the Layout is kind of the master structure of your site.
Views are what you are trying to do at a particular time on a site.
So lets say you are an admin looking at a list of users. So your event might be “users.listusers”
Now when you go to that url, Coldbox loads the “users” handler, and then looks for the “listusers” function. Where it will perhaps call something to load a list of users into a query object.
Then assume listusers sets the view to “users” which might display a table based on the query from “listusers”
That table is output into the layout via the renderView() function.
So far so good I think.
So lets say I have a menu bar at the top of the website which changes depending on who is logged in. In order to get that the menu needs to get a list of items from a menu object to know what to display.
Where does this call to get the menu items fit into the Coldbox workflow?
For example what if it was called from the layout like this renderView(“menu/mainmenu”);
From what I can tell this will not invoke a handler for menu.
I could include the menu call in “listusers” but it seems strange that it would need to be aware of the menu and it’s needs. Not to mention having to put the menu on every handler that “might” use it.
I could include the menu call in onrequest start but now it’s going to be included everytime regardless of wether or not the layout is setup to display it.
It seems to me that the layout which has the render call should somehow be responsible for gathering/invoking the data as well.