Hi everyone,

I'm currently in the process of upgrading our application to ZF 0.9.1 from
0.8 . So far it's going smoothly and I took the oportunity to convert to a
Conventional Modular for convenience and because since the application is an
intranet, it will eventually includes a lot of different modules.

So I based the directory structure on what's described here Conventional
Modular 
Layout<http://framework.zend.com/wiki/display/ZFDEV/Choosing+Your+Application%2527s+Directory+Layout#ChoosingYourApplication%2527sDirectoryLayout-ConventionalModular>to
have something that looks like this:

/application
   /config
       config.ini
   /default
       /controllers
           IndexController.php
       /models
       /views
           /scripts
               /index
                   index.phtml
               _menu.phtml
   /(module x)
       /controllers
           IndexController.php
       /models
       /views
/library
   /Zend
/www
   /images
   /scripts
   /styles
   index.php


In the bootstrap I correctly set the controller directories with:

$controller = Zend_Controller_Front::getInstance();
$controller->throwExceptions(true)
              ->setControllerDirectory(array(
                  'default' => '../application/default/controllers',
                  '(module x)' => '../application/(module x)/controllers'))
              ->setParam('config', $config);


With that setup I can simply use this in the default controller:

   function init()
   {
       $this->initView();
       $this->view->config = $this->getInvokeArg('config');
       $this->view->baseUrl = $this->_request->getBaseUrl();
   }

   function indexAction()
   {
       $this->view->title = 'title';

       $this->view->actionTemplate = '_menu.phtml';
       $this->render();
   }

Which will render the view script in
/application/default/views/scripts/index.phtml in wich the file _menu.phtml
is called with <?php echo $this->render($this->actionTemplate); ?> .

What I'm wondering is where would be a good place to put the site wide view
scripts such as _menu.phtml (also think header/footer scripts) and what
would be the best way to use them inside the modules controller ?

Thanks in advance,

--
Martin Carpentier

Reply via email to