tasmaniski / zend-layout-change

Set different layout per module - Zend Framework 3


Change layout per module

If you have modular app you probably want more that a single layout for eg. admin-layout and web-layout. Currently that is not supported by default in zend framework.

This package will enable you to set different layout for modules.

Install it

Add in your composer.json file:

{
    "require": {
        "tasmaniski/zend-layout-change": "^1.0"
    }
}

After running: sudo composer update you need to register new module.

Add in file config/application.config.php:

'modules' => array(
    '...',
    'LayoutChange'
),

How to Use it

You have to create layout.phtml file per modul. For eg. if you have Admin and Web modules, you should create:

Web/view/layout/web-layout.phtml
Admin/view/layout/admin-layout.phtml

Than in yout config register layouts:

'module_layouts' => [
    'Web' => 'layout/web-layout',
    'Admin' => 'layout/admin-layout',
],

Note: You can define each line in separate module's config: 'module_layouts' => ['Module' => 'layout/layout-name']

Wish you a very Happy New Year!

MIT License

Copyright (c) 2016 Alex

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
php composer.phar require "tasmaniski/zend-layout-change"

Require

  • php: >=5.6