First, i should present the way i manage a web page.

I call component every part of page that could be contained in functional box. Then, header is a component, as there will be a footer component, a pub component, menu, invisible components as tags, etc.. My layout is just the minimum part of static html that will allow to display all or some components in a good way.
Layout contains some 'box' or 'place' that will be filled with components.

The trick is to consider the ZF_view as the layout to render, then the action will only say which components should fill and in which part of layout. In this way, the layout will render all components in one pass. To make a reference to the two step view method, this could be named one step view or rather one step layout method. An obvious gain is you can render in one pass as much components as you want.

I implement it without any dev, just ZF RC1 out of box.

Roughly speaking, in the controller init() method, i will set the view as the layout. Of course, it could more efficient and easier to use if it was integrated to viewRenderer. ViewRenderer should had a layout mode, then we wont have to force
ScriptAction in init() of controller. It could be easily done later.


To go a little farther, i have write a little config file layouts.ini and a class to parse it where i can tell which layout should be used depending on module, controller and action.
For each layout, i can also defined a default components list.

#The most specific entry will be choose.
[layouts]
moduleName.layout = layoutName
moduleName.controllerName.layout = layoutName
moduleName.controllerName.actionName.layout = layoutName
# unlisted module will get the default module layout

[components]
layoutName.blocName[] = componentName
...

As i'm not confortable in english, you can find an implementation example in a zip file below.
This is really basic layouts and components.
http://titerm.free.fr/ZF/samples.zip


In each action, we can
Specify a layout instead default one
Specify what components should go and in which part of layout or accept default components layout
Give data needed by components  if necessary.
Call action helper

In components or layouts, view helpers are available.

I'll answer any question after my holidays.

Thanks.

Laurent

Reply via email to