Is it possible to set more than 1 layout files? Our system has a standard menu layout, and some individual layouts for specific pages. How would I go about doing this?
The event object only holds one layout and one view as the “main” files, but you can use an unlimited amount of views or layouts per page. You just manually render them wherever you see fit inside the “main” layout and view with renderLayout() and renderView(). typically you see this more with views than layouts, since layouts have the default #renderView()# bit in them that renders the main view set in the event.
So a layout could conceivably look like this:
#renderView(“header”)#
#renderView(“menus”)#
#renderView()#
#renderLayout(“sideNav”)#
#renderView(“footer”)#
i actually prefer to wrap my views in an event so if they need data from the database, they can get it from their own wrapper event and the main event doesn’t have to supply it. When doing that just renderView() directly in the handler and return its results and output the event like so in your layout/views:
Where the layout.cfc handler has a method called “menu” that does this:
function menu(event,rc,prc) {
var menuData = service.call();
return renderView(view=‘menu’, args={menuData = local.menuData});
}
using args makes the data specific to just that view call without clogging up the rc and prc scopes.
Hope that helps.
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com