开发者

How do I set separated layouts for each module?

开发者 https://www.devze.com 2023-01-13 04:49 出处:网络
I have my config file like this [production] phpSettings.displa开发者_如何学JAVAy_startup_errors = 1

I have my config file like this

[production]
phpSettings.displa开发者_如何学JAVAy_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] =

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[database]
resources.db.adapter               = PDO_MYSQL
resources.db.params.dbname         = "ccgss"
resources.db.params.username       = "root"
resources.db.params.password       = ""
resources.db.params.hostname       = "localhost"
resources.db.isDefaultTableAdapter = true

[layout]
layoutPath = APPLICATION_PATH "/modules/default/layouts"
contentKey = "content"

This works for the default module, but then I have the admin panel and the layout is completely different. How do I set the layout for the admin module?


In application.ini:

resources.layout.layout = "layout"
resources.layout.layoutPath = APPLICATION_PATH "/layouts"
admin.resources.layout.layout = "admin"
admin.resources.layout.layoutPath = APPLICATION_PATH "/modules/admin/layouts"

You may also create a controller plugin switching layout dynamically based on request parameters.

For further information, see: http://blog.astrumfutura.com/archives/415-Self-Contained-Reusable-Zend-Framework-Modules-With-Standardised-Configurators.html


In your controller, you can set the layout:

    $layout = Zend_Layout::getMvcInstance();
    $layout->setLayout('admin');
    $layout->setLayoutPath(APPLICATION_PATH . '/modules/admin/layouts');

Perhaps do it in a preDispatch

0

精彩评论

暂无评论...
验证码 换一张
取 消