views:

29

answers:

2

I have my config file like this

[production]
phpSettings.display_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?

+1  A: 

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

Ashley
Isn't there a way to set it in the module's bootstrap?
Rodrigo Alves
This should work in bootstrap too, assuming that you already bootstrapped the layout resource e.g. `$this->bootstrap('layout')`.
takeshin
+1  A: 

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

takeshin