setting layout file for module inside bootstrap in zend

痞子三分冷 提交于 2019-12-23 02:56:22

问题


My zend application structure:

application
  ->configs
  ->layouts
     ->scripts
        ->admin.phtml
        ->site.phtml
  ->modules
     ->admin(controllers, models, views)
       ->Bootstrap.php
     ->default(controller,models,views) 
       ->Bootstrap.php

I have set the default layout in my application.ini as:

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = "site"

I have two modules: admin and default. How to set the layout file (admin.phtml)for admin module? I want to change the layout from admin module's Bootstrap.php file? Or suggest me which is most easy way?


回答1:


Write this in your Bootstrap.php in the admin folder:

protected function _initLayout()
{
   $layout = Zend_Layout::getMvcInstance();
   $layout->setLayout('admin');
}

With the above two lines you can also change the layout in Controllers and Plugins. If you want to change it in a view, you can do that so:

<?php $this->layout()->setLayout('admin'); // set alternate layout ?>


来源:https://stackoverflow.com/questions/11390948/setting-layout-file-for-module-inside-bootstrap-in-zend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!