Nesting Layouts Possible?


I just finished reading through the Layouts and Views guide:

I'm trying to find out if it's possible next layouts so that I can
have layouts and sub-layouts for a site. As an example, I have a site
with a main layout and navigation that should go on every page. That's
easy enough, I would use my Layout.Main for that... However, I have a
subsection for authenticated users. My initial though was to create a
new layout, Layout.Admin, and all views in the users folder would se
this Layout. However, this creates duplicate code, because the layout
must have all of the same base navigation. I could put all of my site
navigation into a custom tag and have it rendered in both Layouts, but
that also duplicates the layout...

So my question then is, is there a convention for this inside ColdBox,
or should I fall back on standard CustomTag layout methodologies that
I'm used to?



I would suggest breaking into re-usable pieces. Like navigation as a separate view, then you can just render the navigation and even cache it within any layout.

Layout 1:


Layout 2:


But it seems they are different layouts. I would create two different layouts and try to get the reusable content into a tags folder in the views and render them wherever your layout needs them.


That's probably the way I'll go. I'm used to doing stuff like:


    My content, or rendered view, goes here


I think the above will still work just fine in multiple layouts. I'll
get the ability to make the layouts flexible, and still keep all of
the reusable bits in custom tags. They're for layout after all ;-).

My Layout.User would look like this:

<cf_userNavigation />
    My content, or rendered view, goes here


Thanks for the reply.


I recommend you use renderView(), this way your views (tags) can have access to the framework. If not, you will be doing nasty: caller.something in order to get values and the sort.