在zend的bootstrap中设置模块的布局文件 [英] setting layout file for module inside bootstrap in zend
问题描述
我的zend应用程序结构:
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
我在我的application.ini中将默认布局设置为:
I have set the default layout in my application.ini as:
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = "site"
我有两个模块:admin和default.如何设置管理模块的布局文件(admin.phtml)?我想从管理模块的Bootstrap.php文件更改布局吗? 还是建议我这是最简单的方法?
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?
推荐答案
在管理文件夹的Bootstrap.php
中将其写入:
Write this in your Bootstrap.php
in the admin folder:
protected function _initLayout()
{
$layout = Zend_Layout::getMvcInstance();
$layout->setLayout('admin');
}
使用以上两行,您还可以更改Controllers和Plugins中的布局. 如果要在视图中进行更改,可以这样做:
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 ?>
这篇关于在zend的bootstrap中设置模块的布局文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!