Re: question about layouts

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Saturday, January 8, 2011, 7:00:16 AM, Takács János wrote:

> Hi
>
> I created layouts based on this article:
> http://wendefer.blogspot.com/2007/09/handy-tip-for-layouts-in-freemarker.html
>
>>From my web application, I have to serve a basic layout (with menus,
> header, footer, etc.), and a plain layout (plain html, with some basic
> javascript includes).
> The user can visit the webpage, in this case he gets the basic layout,
> or he can access some pages trough a .NET application, in wich case
> the app just loads Internet Explorer in a frame, and passes a GET
> parameter to the page url.
> In the spring mvc controller class, I have to decide the layout, based
> on this GET param.
> So what I did is this: I created multiple templates, page1.ftl,
> page1_basic.ftl, and page1_plain.ftl
>
> page1_basic.ftl contains only this:
> <@layout.basic>
> <#include "page1.ftl" />
> </@layout.basic>
>
> and page1_plain.ftl is this:
> <@layout.plain>
> <#include "page1.ftl" />
> </@layout.plain>
>
> And in the spring class, I pass the name of the view according to the
> GET parameter.  This way I have to create 3 files for every page.
> My question is, is there a simpler way to do this?

For example, you could have a single template like this:

  <@layout[layoutName]>
    <#include pageName + ".ftl">
  </@>

then just call this templates with layoutName and pageName in the
data-model set based on that HTTP request parameter.

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.