title: Module configuration and layout configuration in zend framework
body: <p>I got some codes from other articles for configuring module and layout in zend framework. I tried with in my local. i didn't get different layout for default and admin module. Here is my code for configuring module and layout for zend framework.</p>
  
  <p><strong><em>configs/application.ini</em></strong> </p>
  
  <pre><code>[production]
  
  # Debug output
  phpSettings.display_startup_errors = 0
  phpSettings.display_errors = 0
  
  # Include path
  includePaths.library = APPLICATION_PATH "/../library"
  
  # Bootstrap
  bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
  bootstrap.class = "Bootstrap"
  
  admin.bootstrap.path = APPLICATION_PATH "/modules/admin/Bootstrap.php"
  admin.bootstrap.class = "admin_Bootstrap"
  
  # Front Controller
  resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
  resources.frontController.env = APPLICATION_ENV
  
  # Session
  resources.session.name = "ZendSession"
  resources.session.save_path = APPLICATION_PATH "/../data/session"
  resources.session.remember_me_seconds = 86400
  
  # Layout
  resources.layout.layout = "layout"
  resources.layout.layoutPath = APPLICATION_PATH "/layouts"
  admin.resources.layout.layout = "admin"
  admin.resources.layout.layoutPath = APPLICATION_PATH "/modules/admin/layouts"
  
  # Views
  resources.view.encoding = "UTF-8"
  resources.view.basePath = APPLICATION_PATH "/views/"
  resources.view[] =
  
  resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
  resources.modules[] =
  resources.view[] =
  admin.resources.view[] = 
  
  [staging : production]
  
  [testing : production]
  phpSettings.display_startup_errors = 1
  phpSettings.display_errors = 1
  
  [development : production]
  phpSettings.display_startup_errors = 1
  phpSettings.display_errors = 1
  </code></pre>
  
  <p><strong><em>application/Bootstrap.php</em></strong></p>
  
  <pre><code>&lt;?php
  
  /**
  * Ensure all communications are managed by sessions.
  */
  require_once ('Zend/Session.php');
  Zend_Session::start();
  
  class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
  
       protected function _initDoctype() {
        $this-&gt;bootstrap( 'view' );
        $view = $this-&gt;getResource( 'view' );
        $view-&gt;navigation = array();
        $view-&gt;subnavigation = array();
        $view-&gt;headTitle( 'Module One' );
        $view-&gt;headLink()-&gt;appendStylesheet('/css/clear.css');
        $view-&gt;headLink()-&gt;appendStylesheet('/css/main.css');
        $view-&gt;headScript()-&gt;appendFile('/js/jquery.js');
        $view-&gt;doctype( 'XHTML1_STRICT' );
        //$view-&gt;navigation = $this-&gt;buildMenu();
     }
  
      /*protected function _initAppAutoLoad()
      {
     $autoloader = new Zend_Application_Module_Autoloader(array(
         'namespace' =&gt; 'default',
         'basePath' =&gt; APPLICATION_PATH
          ));
     return $autoloader;
      }*/
  
      protected function _initLayoutHelper()
      {
          $this-&gt;bootstrap('frontController');
          $layout = Zend_Controller_Action_HelperBroker::addHelper(
              new ModuleLayoutLoader());
      }
  
  
     public function _initControllers()
     {
         $front = Zend_Controller_Front::getInstance();
        $front-&gt;addModuleDirectory(APPLICATION_PATH . '/modules/admin/', 'admin');
      }
  
      protected function _initAutoLoadModuleAdmin() {
          $autoloader = new Zend_Application_module_Autoloader(array(
              'namespace' =&gt; 'Admin',
              'basePath' =&gt; APPLICATION_PATH . '/modules/admin'
          ));
  
          return $autoloader;
      }
  
      protected function _initModuleutoload() {
        $autoloader = new Zend_Application_Module_Autoloader ( array ('namespace' =&gt; '', 'basePath' =&gt; APPLICATION_PATH ) );
        return $autoloader;
     }
  
  }
  
  class ModuleLayoutLoader extends Zend_Controller_Action_Helper_Abstract
  // looks up layout by module in application.ini
  {
      public function preDispatch()
      {
          $bootstrap = $this-&gt;getActionController()
                            -&gt;getInvokeArg('bootstrap');
          $config = $bootstrap-&gt;getOptions();
          echo $module = $this-&gt;getRequest()-&gt;getModuleName();
          /*echo "Configs : &lt;pre&gt;";
          print_r($config[$module]);*/
          if (isset($config[$module]['resources']['layout']['layout'])) {
              $layoutScript = $config[$module]['resources']['layout']['layout'];
              $this-&gt;getActionController()
              -&gt;getHelper('layout')
              -&gt;setLayout($layoutScript);
          }
      }
  }
  </code></pre>
  
  <p><strong><em>application/modules/admin/Bootstrap.php</em></strong></p>
  
  <pre><code>&lt;?php
  class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
  {
  /*protected function _initAppAutoload()
  {
      $autoloader = new Zend_Application_Module_Autoloader(array(
          'namespace' =&gt; 'admin',
          'basePath' =&gt; APPLICATION_PATH . '/modules/admin/'
      ));
      return $autoloader;
  }*/
     protected function _initDoctype() {
        $this-&gt;bootstrap( 'view' );
        $view = $this-&gt;getResource( 'view' );
        $view-&gt;navigation = array();
        $view-&gt;subnavigation = array();
        $view-&gt;headTitle( 'Module One' );
        $view-&gt;headLink()-&gt;appendStylesheet('/css/clear.css');
        $view-&gt;headLink()-&gt;appendStylesheet('/css/main.css');
        $view-&gt;headScript()-&gt;appendFile('/js/jquery.js');
        $view-&gt;doctype( 'XHTML1_STRICT' );
        //$view-&gt;navigation = $this-&gt;buildMenu();
     }
  }
  </code></pre>
  
  <p>Please go through it and let me know any knows how do configure module and layout in right way..</p>
  
  <p>Thanks and regards,</p>
  
  <p>Prasanth P</p>