View Single Post
  #2 (permalink)  
Old 07-10-2007, 02:28 PM
sbarre sbarre is offline
Junior Member
 
Join Date: Jul 2007
Posts: 1
Default

Unless I'm mistaken, if you manually instance your view class in your bootstrap, via the ViewRenderer helper (which gets registered in the Helper Broker), then that one will be used throughout your controllers.

Zend Framework: Documentation

Before you register your Zend_View class with the Helper, just assign the path there.

As a more generic solution to these kinds of problems, you may also want to consider using an intermediate Controller subclass for your application-wide settings, so that you can do app-specific stuff like this once only.

So instead of having Your_Controller (for example) extend Zend_Controller_Action directly, you create App_Controller that extends Zend_Controller_Action (and optionally <Module>_Controller that extends App_Controller if your are using modules, and have <Module> be the name of your module) and then have Your_Controller extend either App_Controller or <Module>_Controller as is appropriate.

This technique allows you to put stuff in the init() methods of App_Controller and <Module>_Controller that get applied to all the subclass controllers easily and once only, and makes maintenance easier and keeps your code more elegant.
Reply With Quote