-- Kevin McArthur <[EMAIL PROTECTED]> wrote (on Tuesday, 29 May 2007, 10:09 AM -0600): > How do you tie in context-sensitive things like menu's or breadcrumbs?
I use a persistent view object, so typically I'll set variables in the view that I then check against and/or use directly in the site template, and ignore in the application template. > ----- Original Message ----- > From: "Matthew Weier O'Phinney" <[EMAIL PROTECTED]> > To: <[email protected]> > Sent: Tuesday, May 29, 2007 9:53 AM > Subject: Re: [fw-general] ViewRenderer and nested templates > > > >-- Kevin McArthur <[EMAIL PROTECTED]> wrote > >(on Tuesday, 29 May 2007, 09:43 AM -0600): > >>Surely, nested templates will have some sort of built-in basic > >>functionality. I dont know many PHP developers who use templates like > >>they're a series of concatenated strings. It just doesn't jive with the > >>nested nature of html. > >> > >>Most PHP apps follow a standard/shared layout approach; so whats the > >>'framework' way of handling common elements now? render header, content, > >>footer? > > > >I use the Two Step View pattern. My applications render content to the > >response object (just the application content, none of the site > >skeleton), and then in a dispatchLoopShutdown() plugin I pull the > >response content and inject it into a sitewide template, and finally > >inject that rendered content back into the response object. I've > >provided a sample of such a plugin in the past on either the fw-mvc or > >fw-general list. > > > > > >>----- Original Message ----- > >>From: "Rob Allen" <[EMAIL PROTECTED]> > >>To: <[email protected]> > >>Sent: Tuesday, May 29, 2007 2:09 AM > >>Subject: Re: [fw-general] ViewRenderer and nested templates > >> > >> > >>>Kevin McArthur wrote: > >>>>Hi Guys, > >>>> > >>>>I'm trying to upgrade several sites to 1.0 but my sites tend to use a > >>>>main template (engine.tpl) plus a set of sub templates (actionName.tpl) > >>>>(menu.tpl) etc... it seems fairly evident how to sub-render, but with > >>>>outer most template always being the same file, how do you set this > >>>>with > >>>>the view renderer's automatic actions to set the $view->content > >>>>variable > >>>>to the actionName template automatically. > >>>> > >>> > >>> > >>>Currently, I'm exploring extending ViewRender's renderScript() to do > >>>something similar. > >>> > >>>My first attempt looks like this: > >>> > >>>class My_Controller_Action_Helper_ViewRenderer > >>>extends Zend_Controller_Action_Helper_ViewRenderer > >>>{ > >>> public function renderScript($script, $name = null) > >>> { > >>> if (null === $name) { > >>> $name = $this->getResponseSegment(); > >>> } > >>> $content = $this->view->render($script); > >>> > >>> $this->view->content = $content; > >>> > >>> $layoutTemplate = 'site.tpl.php'; > >>> $this->getResponse()->appendBody( > >>> $this->view->render($layoutTemplate), > >>> $name > >>> ); > >>> > >>> $this->setNoRender(); > >>> } > >>>} > >>> > >>> > >>>I also have: > >>> > >>> $viewRenderer = new My_Controller_Action_Helper_ViewRenderer(); > >>> $viewRenderer->setViewSuffix('tpl.php'); > >>> Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); > >>> > >>>in my bootstrap before I first instantiate the front controller, so that > >>>my ViewRenderer is used. > >>> > >>> > >>> > >>> > >>>Regards, > >>> > >>>Rob... > >>> > >> > > > >-- > >Matthew Weier O'Phinney > >PHP Developer | [EMAIL PROTECTED] > >Zend - The PHP Company | http://www.zend.com/ > -- Matthew Weier O'Phinney PHP Developer | [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
