I have a component proposal (writing it as we speak) for Zend_Layout. A
full working implementation can be found at
http://svn.ralphschindler.com/repo/Xend/
(executed in the Xend_Layout namespace) minimal docs and usage is in the
docs folder.. Several people on #zftalk have had a chance to implement
this solution with great ease.
I will post back when the proposal is updated on the wiki.
More to come,
-ralph
Extract from pending proposal:
Zend_Layout attempts to solve a problem that, since rearing its ugly
head over and over, has gone by many names: Composite Views, Layouts,
Templates, Partial Views, and/or Complex Views. They all basically
attempt to describe a common problem - that of being able to maintain a
consistent look and feel throughout a site or web application while
maintaining the "Don't Repeat Yourself" principals.
Zend_Layout addresses the problem with a common pattern, the
two-step-view pattern
(http://www.martinfowler.com/eaaCatalog/twoStepView.html). The Two Step
View pattern breaks the process up into two distinct stages. The
primary stage allows the user requested action as well as layout
requested actions to dispatch and execute their respective views saving
them to the controllers response object. The second stage of the
process takes the already dispatched actions responses and directs them
to the layout where final placement of content is made (in a Layout
specific view) before being sent back to the user.
Zend_Layout requires no changes to the existing codebase to accomplish
its job. To maintain controller over the dispatch process, Zend_Layout
attaches a controller plugin - this is the essense of the Two-Step-View
and common way to implement the 2SV as we have seen already.
Zend_Layout also registers its own action helper (named LayoutManager),
so that the developer can directly interact with Zend_Layout from within
their actions.
David Mintz wrote:
This newbie is liking the Two Step View where your plugin basically
intercepts the response body and sticks it into a sitewide template at
dispatchLoopShutdown() time.
So: if you want all your controllers to use a common Zend_View object
(so that the view vars they set will end up available to the sitewide,
enclosing template), what approach would you recommend? In the name of
DRY it seems you would might have your bootstrap put the new Zend_View()
in the registry, and
class MyAppController extends Zend_Controller_Action
{
public function init() {
$this->view = Zend_Registry::get('view');
}
}
and then have your controllers extend MyAppController instead of
Zend_Controller_Action. Thoughts?
--
David Mintz
http://davidmintz.org/
"Our universe is just one of those things that happens from time to time."