petrofcikmatus/zf-layout-change

This package is abandoned and no longer maintained. No replacement package was suggested.

Zend Framework module for layout change based on used controller namespace.

1.0.0 2017-07-20 21:56 UTC

This package is auto-updated.

Last update: 2020-08-07 15:06:33 UTC


README

This is a Zend Framework 3 module, that can simply set different layouts for different modules.

If you have multiple modules in your application (e.g. Application and Admin), and you want different layout for some module (e.g. Admin), this package will provide easiest way to do that change.

How to use this package

1. Install this module with composer

Simplest way to install this package is to use following composer command to require dependency:

composer require petrofcikmatus/zf-layout-change

Alternatively you can add following to your composer.json file manualy:

{
  "require": {
    "petrofcikmatus/zf-layout-change": "dev-master"
  }
}

and execute composer command to update your dependencies (and also download this new one):

composer update

2. Add this module to your modules

When you add this package with composer, it should automatically ask in which file you want add new module.

If this did not happen, you have to add 'ZFLayoutChange' value to the array with your modules. It should be in file config/application.config.php or config/modules.config.php, and look like this:

<?php

return [
    'modules' => [
        // your other modules
        
        'ZFLayoutChange', // new line
    ],
];

3. Add array with layouts for your modules

Add a new array with key module_layouts in your global configuration file config/autoload/global.php, or to module.config.php for some modules if you want.

<?php

return [
    // your other config arrays
    
    'module_layouts' => [
        'Admin' => 'layout/admin',
    ],
];

In the example above, controllers in Admin module (and namespace) will use layout layout/admin. Otherwise, it will use default configured layout.

4. That is all!

Enjoy your layout changing :)

See a bug? Want to contribute?

If you see any bug or you experience any troubles, please open a new issue or commit bugfix, I will look at it.

If you want to change something (maybe I didn't make it the best way), feel free to fork repository and create new merge requests.

Also if you want this on Zend Framework 2, feel free to contribute. I do not use ZF2 anymore, so it is up to you now.

License

This module uses MIT license.