This is almost too interesting. While waiting for an answer I went ahead and tried my own suggestion and somehow broke something -- still don't understand what. I determined that the $this of the embedded view scripts -- the ones whose output was getting put into $this->content by the dispatchLoopShutdown() hook -- was not a reference to the same Zend_View object as the $this->view of the plugin. It seems it should have worked but did not; and conversely, once I stopped using the view object from the registry in my controllers, it seems it should not have worked but it did. I could show you the code but let's just move on instead. I will play with the suggestion below, and keep waiting patiently for Zend_Layout as well.
As an aside, I come at this from a different angle from most of you guys who sound like you really know what you're doing. I am a relative lightweight with a non-IT job description, but I've been doing web stuff ever since the days when people used a Perl library called cgi-lib.pl, and have come a long way. An MVC framework like ZF makes your life way easier in the long term, undoubtedly, but it isn't for wimps. It's interesting to see if an intermediate(?) developer can get his head around the complexity enough to use ZF productively. I think it is possible -- moreso than with something like CakePHP even. Many thanks. On 6/21/07, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:
-- David Mintz <[EMAIL PROTECTED]> wrote (on Thursday, 21 June 2007, 12:45 PM -0400): > 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'); > } > } [...] There's another way to do this now with the ViewRenderer: class My_TwoStep_Plugin extends Zend_Controller_Plugin_Abstract { public function dispatchLoopShutdown() { $viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer'); $view = $viewRenderer->view; // ... do the rest... } } No registry needed. :-) You can also seed the ViewRenderer with a customized view object in your bootstrap: $view = new Zend_View($options); $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view); Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); -- Matthew Weier O'Phinney PHP Developer | [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
-- David Mintz http://davidmintz.org/ "Our universe is just one of those things that happens from time to time."