[FLOW3-general] A TemplateView Extension: CompositeTemplateView

Manuel Strausz tminus at bitmap.co.at
Tue Jan 5 16:46:15 CET 2010


Hey everyone,

As my first FLOW3 related mini-project I created a new kind of Fluid 
TemplateView class. It introduces the possibility of mapping view 
objects to section names and displaying them with the the render 
view-helper.
Currently it simply reuses the syntax and functionality for sections for 
displaying:
<f:render section="childView">

The advantage compared the current Layout/Section system is that it's 
possible to display a tree of nested CompositeTemplateViews. With a 
Layout it would only be possible to have one layer of Sections below it 
(as far as I understand it so far, anyway :)).

E.g. it would be possible to have a Layout with a master.html, which has 
a section for a list template, which again has a sub-section for list 
items. With nested views you could use a displayItem.html to define the 
layout of each item, or exchange it for an editItem.html when you want 
to put a certain item in edit mode.

The disadvantages are that it's a bit clumsy to define TemplateView 
objects by hand at the moment, since you need to set the template-path 
manually. In my tests I had to make the protected getTemplateRootPath 
method of TemplateView public, so I could generate to references the 
templates myself. Also it adds a bit of an overhead if you are 
displaying many nested views on one page, but this could be solved with 
proper caching.

I also introduced a package-level setting which allows to set the 
defaultTemplateView class that is used for Fluid templates, since the 
CompositeTemplateView inherits the normal TemplateView it can be used in 
the same way without having to add child views.
Of course I also had to change some code in the ActionController to make 
this setting work, that's about the only thing preventing it to be a 
simple Addon without interfering with the Framework packages.

So, I'm just posting this here to ask if there is any general need for 
this. If yes I'll gladly integrate it into the Framework and supply some 
patches, but I can also just keep it as an Addon for now.

Happy New Year everyone & happy coding ;)

greets,
Manuel


More information about the FLOW3-general mailing list