I am new to Grails/GSP/Sitemesh and am trying to figure out if I can use nested layouts. I would like to have a main layout that will be used for all of my pages to contain a standard header, footer, and all my CSS/JavaScript resources. On another subset of pages I would like to define a layout that will inherit from the main one and add a side menu and a few other things. That way each of my pages for that section references the second layout and automatically gets the content from it along with the main layout.
Is this possible to do? How do I define the second layout to reference the main one to make this work?
Update 1
So, I read through the blog article linked to in a comment below and am still having trouble. I tried setting up a very simple test case with the following hierarchy.
/layouts/main.gsp
-- /layouts/sub.gsp
-- /test/index.gsp
For my pages I have the following... in main.gsp:
<!DOCTYPE html>
<html>
<head>
<title><g:layoutTitle default="Grails"/></title>
<g:layoutHead/>
</head>
<body>
MAIN <br />
<g:layoutBody/>
</body>
</html>
in sub.gsp:
<g:applyLayout name="main">
<html>
<head>
<title><g:layoutTitle/></title>
<g:layoutHead/>
</head>
<body>
Sub<br />
<g:pageProperty name="page.content"/>
</body>
</html>
</g:applyLayout>
and finally in index.gsp:
<html>
<head>
<meta name="layout" content="sub"/>
<title>Title Here</title>
</head>
<body>
<content tag="page.content">
Content
</content>
</body>
</html>
When I load my page the page title is set correctly, and I see "Main" and "Sub" rendered on the page, but "Content" is not shown. I'm sure I must be doing something simple wrong... any ideas?
Update 2
I figured out that I had <content tag="page.content">
and it should have just been <content tag="content">
. Seems to be working now.