Reputation: 27038
i have a bare bones zf2 application and i have 2 modules (Users and Album).
They both have their own layouts but i want to use the layout from Album for the Users, just to keep them a bit more consistent.
Im not sure what is the best way to delegate what layout a module should use.. from the controller __contruct, or on each individual action or in the module.config.php.
maybe here:
'template_map' => array(
'layout/top_nav' => __DIR__ . '/../view/layout/top_nav.phtml',
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
^^ probably i should set this path to the layout i want to use ^^
'posts/index/index' => __DIR__ . '/../view/posts/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
any ideas? maybe the best practices?
thanks
edit: i just did this and it worked:
'layout/layout' => __DIR__ . '/../../album /view/layout/layout.phtml',
but i'm still not sure if this is best practice.
maybe i can setup multiple template_map
arrays and use them in the User
controller, in my case
Upvotes: 0
Views: 2937
Reputation: 16455
Edit: removed my own bullshit, just see the alternative approach :) That works
Alternative approach
Evan Coury also made the effor to have the Layout configuration globally available. This is especially true for single developers who won't make their modules public, ever. You will find his EdpModuleLayouts Module right here.
Using that module switching layouts becomes even simpler like the following:
<?php
array(
'module_layouts' => array(
'ModuleName' => 'layout/some-layout',
),
);
Hope it helps.
Upvotes: 4