Differences between revisions 1 and 2
Revision 1 as of 2005-01-21 02:02:28
Size: 3290
Editor: ScottEade
Comment: Migrated page.
Revision 2 as of 2009-09-20 22:00:05
Size: 3287
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
With the change to [wiki:Turbine2/VelocityOnlyLayout VelocityOnlyLayout] from the VelocityECSLayout, the idea has come up (again) for a way to embed layouts. With the change to [[Turbine2/VelocityOnlyLayout|VelocityOnlyLayout]] from the VelocityECSLayout, the idea has come up (again) for a way to embed layouts.

With the change to VelocityOnlyLayout from the VelocityECSLayout, the idea has come up (again) for a way to embed layouts.

This idea has been thrown around before by Rafal Krzewski:

Some time ago, an idea crossed my mind, that we might want to introduce another layer of templating, namely Page template. It would contain the common elements of all Layout templates used in conjuncion with VelocityOnlyLayout class. An application will use precisely one Page template, the same way as it uses single Page class now. This would bring us back to the separation between head and body parts of the page we had with ECS, but with template driven customization of head elements available to the developer.


A variation on this idea was proposed by Chris Felaco:

I had added a hack^H^H^H^Hfeature to my customized Layout to enable layouts to be embedded within other layouts. This way you can have a standard layout containing just the basic HTML HEAD and BODY tag stuff, and then reuse that layout in other layouts.

The way to do it is for the layout template itself to change the layoutTemplate in the TemplateInfo. When the Layout class is done rendering the template using Velocity, it checks if the layoutTemplate name was changed, and if so, it sets the $screen_placeholder to the original layout content and then renders the new layout template. Repeat as necessary. The explanation is not very clear - here's the basic code:

    /* 
     * Grab the layout template set in the TemplatePage. 
     */ 
    String templateName = data.getTemplateInfo().getLayoutTemplate(); 

    /* 
     * Finally, render the layout template. 
     */ 
    String layoutContent = TurbineVelocity.handleRequest( 
        context, "layouts" + templateName); 

    // If the template itself changes the layoutTemplate, then it wants to 
    // be embedded inside it.  This allows for any level of nesting, so beware 
    // of infinite recursion. 
    while (! templateName.equals(data.getTemplateInfo().getLayoutTemplate())) 
    { 
      templateName = data.getTemplateInfo().getLayoutTemplate(); 

      context.put("screen_placeholder", layoutContent); 

      layoutContent = TurbineVelocity.handleRequest( 
        context, "layouts" + templateName); 
    }
  • Note that the embedding does not involve looking up the Layout class for the template that is being embedded in. This is only for reusing content.

    Does this idea appeal to anyone for general use in Turbine?

    On a related note, I think it would make sense for "navigations" to be available within the screens. This would make it much easier to create widget-like templates with smart functionality that can be reused throughout the site. It would be akin to portlets in a sense.

    - Chris

'Attila'

I would love to have the ability to add "navigation" to my portal. To make sure we are all on the same page ('hahah'), I would love to add something like 'iteam 1.0 | subitem 1.1 | subitem 1.1.3 | etc'. I have a portal that has a number of widget-like templates when people fill in details and in layers. It would be great if we could have this navigation as a feature.

Turbine2/WishList/PageLayout (last edited 2009-09-20 22:00:05 by localhost)