Search code examples
grailsgsp

How to apply layout and templates to other controller folder?


I want to apply my layouts/main.gsp layout to the user/login page. my main.gsp has reference to other css and refernces to the templates :

</head>

<body>

<g:render template = "templates/headerTop" contextPath = "/"></g:render>

<g:render template = "templates/menuHeader" contextPath = "/"></g:render>
<g:layoutBody/>
<g:render template="templates/footer" contextPath = "/"></g:render>

</body>

But when i run the application and go to login click it says it can not find the template path. I understand that since login is in 'user' folder so it is not able to search the path. Question is : how to apply layout to my login page.


Solution

  • You need to specify absolute path to your templates:

       <g:render template = "/templates/headerTop" contextPath = "/"></g:render>