how to do multi level layout

* A site has the default global layout and navigation links.
* Within the site, it has several different sections,
* each section has many pages, which has same sub nav links and some
common parts.

* how do i wrap a section page with section layout first, and then
global layout?
* what's the best way to handle such multi level layout situation?

Two solutions I tried, and I don't like either one.
1. create a layout for each section, the layout duplicate global
layout elements
2. only use global layout, then render partial section_header,
section_footer on every single page.

thanks.

thanks.
Dorren

but a "global.rhtml" layout,
which calls "render :partial => "section_links""

would render "_section_links.rhtml"
in the appropriate directory.

so in the users controller it'll render /users/_section_links.rhtml
and in the product controller it does /product/_section_links.rhtml.

maybe that's what you want.

This will work if all sections are very similar, and require every
section to have section_links.rhtml, which should be ok in most
situations.

through trial and error, i found out this setup is more flexible. To
use namespace in layout file, and rename layout as partial.
so I copy layouts/application.rhtml to shared/layouts/
_application.rhtml

======== shared/layouts/_application.rhtml =============
<html>
<head>
.....
<body>
<%= render(:partial => "/shared/global_header") %>
<div id="section_header"><%= yield "top" %></div>

<div id="main"><%= yield %></div>

<%= render(:partial => "/shared/global_footer") %>
</body>
</html>

======== layouts/product.rhtml =============
<% content_for :top do %>
  product_home | hardware | software | ...
<% end %>

<%= render(:partial => "/shared/layouts/application") %>

======== layouts/support.rhtml =============
<%= render(:partial => "/shared/layouts/application") %>

Product section wants a section navbar on top, so it just do that in
the product layout, for ProductController
Support section don't need navbar, so it just skips it.

one drawback, namespaced part can not be cached.

Dorren

I hope my question is consistant with your thread. I have a VERY large
application with all kinds of sub-applications such as forums, diggs,
blogs, etc. and wish to split up the \application\app metaphor to be
\application\app\subprogram. Has anyone done this?
I see following your thread how you'd handle calling views, but what
about models and controllers?
I am grateful for any reply.
Thanks,
Kathy

This PDF from a rails conf presentation has some interesting ideas:
http://culann.com/slides/Static_Site_Railsconf_2007_final.pdf

I ran into a similar problem and came across the following discussion
about "nested layouts" which provides some good insight into the
matter:

http://errtheblog.com/post/28

it seems there's also a nested-layout plugin available which I haven't
had any experience with..

Mike

Some good ideas in this presentation but if I understand the OP's
question, it's about having multiple tiers of layout. Sort of like
(tags omitted for brevity):

<!-- layout.erb -->
<html>
<!-- xhtml'ey stuff -->
<%= render :partial => yield :section_layout %>
</html>

<!-- _my_section_layout.erb -->
<div>
Hi! Welcome to the chunky bacon section
</div>
<%= yield :layout %>
<div>
goodbye to the chunky bacon section
</div>

<!-- my_view.erb -->
<% content_for :section_layout do %>my_section_layout<% end %>
<p>
   Other stuff specific to the particular view. Note that the section
layout can also be set in the controller using
@content_for_section_layout.
</p>

I'm not positive this works, and you might have to "help" Rails
understand the search path for the section layouts, but it's worth a
try.

perhaps I'm misunderstanding but why not this:

http://agilewebdevelopment.com/plugins/nested_layouts

chau!
Tim