不同模块的多种布局-Zend Framework
问题描述:
我对Zend Framework中的布局有疑问. 这是我的项目结构:
I have a question about layouts in Zend Framework. This is my structure of my project:
- 我有2个名为"backoffice"和"frontoffice"的模块.
- 我在后台和前台的布局/脚本中都有一个layout.phtml.
- 现在我要为后台办公室"和前台办公室"分别设置布局/脚本"
- 在我的application.ini中,我有:
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
- I have 2 modules named "backoffice" and "frontoffice".
- I have one layout.phtml in layouts/scripts for both the backoffice and frontoffice.
- Now I want seperate "layouts/scripts" for "backoffice" and "frontoffice"
- In my application.ini I have:
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
现在如何解决具有单独布局的问题?
Now how can I fix this that I have seperate layouts?
答
只需在layout/scripts
文件夹中放置另一个布局,并告诉任何模块,控制器或操作使用该其他布局而不是默认布局.
Just place another layout in the layout/scripts
folder and tell any module, controller or action to use that other layout instead of the default layout.
如果要让控制器使用其他布局,可以在init()
If you want to let a controller use a different layout, you can place the following in your init()
$this->_helper->layout->setLayout('layoutname');
您可以分别针对特定操作或整个模块执行此操作.
You can do that respectively for specific actions or for a whole module.